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

Regexify dot issue #133

Closed
IonBazan opened this issue Dec 11, 2020 · 0 comments · Fixed by #135
Closed

Regexify dot issue #133

IonBazan opened this issue Dec 11, 2020 · 0 comments · Fixed by #135
Labels
bug Something isn't working

Comments

@IonBazan
Copy link

Summary

regexify does not handle [.] properly. It should treat it as literal ., not "any character" when it is in square brackets. This can be reproduced with test:

public function testRegexifyBasicFeatures($input, $output, $message)
{
self::assertEquals($output, BaseProvider::regexify($input), $message);
}

using following data set:
['[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}', 'complex regex']
without seeding the generator (to assure randomness).

Versions

Version
PHP 7.4
fakerphp/faker 1.12.0

Self-enclosed code snippet for reproduction

<?php
$regex = '/[.]/';
$result = \Faker\Provider\Base::regexify($regex);
var_dump(preg_match($regex, $result));

Expected output

int(1); // result should match the regex

Actual output

int(0); // result does not match the regex
@IonBazan IonBazan mentioned this issue Dec 11, 2020
4 tasks
@pimjansen pimjansen added the bug Something isn't working label Dec 17, 2020
pimjansen pushed a commit that referenced this issue Dec 19, 2020
* fix regexify dot in braces

* add test

* add test

* add test

Signed-off-by: Daniel Schmelz <daniel@schmelz.org>

* add dot test

Signed-off-by: Daniel Schmelz <daniel@schmelz.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants