Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Validator\Numericality If not continuous, many letters and symbols will slip through #16070

Closed
s-ohnishi opened this issue Aug 24, 2022 · 4 comments · Fixed by #16071
Closed
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@s-ohnishi
Copy link

Validator\Numericality::validate() uses this regular expression according to .zep.
pattern = "/((^[-]?[0-9,]+(.[0-9]+)?$)|(^[-]?[0-9.]+(,[0-9]+)?$))/";

But isn't (.[0-9]+)? a mistake for (\.[0-9]+)??

Details

  • Phalcon version: 5.0.0 RC4
  • PHP Version: 8.1.9
  • Operating System: Debian on Docker (WSL2)
  • Installation type: Compiling from source
  • Zephir version (if any):
  • Server: Nginx/1.22.0
@s-ohnishi s-ohnishi added bug A bug report status: unverified Unverified labels Aug 24, 2022
@niden
Copy link
Sponsor Member

niden commented Aug 24, 2022

Can you give an example of a string that would fail this?

@s-ohnishi
Copy link
Author

define form

class SampleForm extends \Phalcon\Forms\Form
    public function initialize($entity = null, $options = [])
    {
        $elm = new Element\Text('foo');
        $elm->addValidator(
            new Validator\Numericality([
                'message'=>'enter numeric value, please',
                'allowEmpty'=>true
            ]),
        );
        $this->add($elm);
    }
}

in the controller

        $SampleForm = new \App\Forms\SampleForm();
        $ret = $SampleForm ->isValid($_POST);

results

$_POST['foo']   $res
'-12,000'       true
'-12,0@0'       true
'-12,0@@0'      false

Would you like a sample like this?

@niden
Copy link
Sponsor Member

niden commented Aug 24, 2022

Yes. Thank you. I will fix this shortly

@niden niden self-assigned this Aug 24, 2022
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Aug 24, 2022
@niden niden added this to Working on it in Phalcon Roadmap Aug 24, 2022
niden added a commit to niden/cphalcon that referenced this issue Aug 24, 2022
niden added a commit to niden/cphalcon that referenced this issue Aug 24, 2022
niden added a commit to niden/cphalcon that referenced this issue Aug 24, 2022
@niden niden mentioned this issue Aug 24, 2022
5 tasks
@niden niden linked a pull request Aug 24, 2022 that will close this issue
5 tasks
@niden
Copy link
Sponsor Member

niden commented Aug 24, 2022

Resolved in #16071

Thank you @s-ohnishi

@niden niden closed this as completed Aug 24, 2022
Phalcon Roadmap automation moved this from Working on it to Implemented Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Archived in project
Phalcon Roadmap
  
Implemented
Development

Successfully merging a pull request may close this issue.

2 participants