GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Form Validation Methods Broken by Forced Lowercasing · Issue #138 · leafsphp/docs

Form Validation Methods Broken by Forced Lowercasing #138

New issue
Copy link
New issue
Copy link
Open
Open
Form Validation Methods Broken by Forced Lowercasing#138
Copy link

Description

@emajekral-collab
emajekral-collab
opened on Jun 13, 2026
Issue body actions

Hi,

There is a bug in validation that affects 'regex', 'match' and 'contains' tests. The parameters for these rules are forced to lower case so matches to fields with upper case values are not possible.

As of Form 3.2 (current) in \Leaf\Form:test we see:

       foreach ($rule as $currentRule) {
            $param = [];

            $currentRule = strtolower($currentRule);  // TOO EARLY | NOT NEEDED?

            if ($currentRule === 'optional') {
                continue;
            }

            if ($currentRule === 'expanded') {
                continue;
            }

            if (preg_match('/^[a-zA-Z]+<(.*(\|.*)*)>$/', $currentRule)) {  // MOVE UP??
                $ruleParts = explode('<', $currentRule);
                $ruleParams = str_replace('>', '', $ruleParts[1]);

                $currentRule = $ruleParts[0];
                $param = $ruleParams;
            }

            if (strpos($currentRule, ':') !== false && strpos($currentRule, '|') === false) {  // MOVE UP??
                $ruleParts = explode(':', $currentRule);

                $currentRule = trim($ruleParts[0]);
                $param = $ruleParts[1] ? trim($ruleParts[1]) : null;
            }

Commenting out strtolower solves my problem, but I think it is useful since it allows rule names to be more flexible with regards to capitalization.

The strtolower($currentRule) comes too early - it forces $param to lowercase since it is split from $curretnRule afterward. This breaks most useful regular expressions. I suggest moving the checks to split out parameters to immediately after $param is declared. Possibly also the previous if statement.

I'm not sure how this interacts with validation of indexed arrays. It's not clear to me how parameters are handled in this case

Thanks for your attention to this!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.