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

Bugfix: Fix unescaped dash in character group in regex #14224

Closed
wants to merge 1 commit into from

Conversation

@mvorisek
Copy link
Contributor

commented Jun 14, 2019

Questions Answers
Branch? 1.7.6.x
Description? PHP needs 2 backslashes to produce one backslash in the string itself.
Regex needs 2 backslashes to produce one backslash in the regex itself.
Type? bug fix
Category? BO
BC breaks? no
Deprecations? no
How to test? Try with php7.3

This change is Reviewable

Fix unescaped dash in character group in regex
PHP needs 2 backslashes to produce one backslash in the string itself.
Regex needs 2 backslashes to produce one backslash in the regex itself.

@mvorisek mvorisek requested a review from PrestaShop/prestashop-core-developers as a code owner Jun 14, 2019

@prestonBot

This comment has been minimized.

Copy link
Collaborator

commented Jun 14, 2019

Hello @mvorisek!

This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community!

@@ -286,9 +286,9 @@ protected function getClassesFromDir($path, $hostMode = false)
} elseif (substr($file, -4) == '.php') {
$content = file_get_contents($rootDir . $path . $file);
$namespacePattern = '[\\a-z0-9_]*[\\]';
$namespacePattern = '[\\\\a-z0-9_]*[\\\\]';

This comment has been minimized.

Copy link
@PierreRambaud

PierreRambaud Jun 17, 2019

Contributor

We're in a quote context.

echo '\t';  // => '\t'
echo "\t"; // => '	'

Can you give us an example where it fails? 🤔

This comment has been minimized.

Copy link
@mvorisek

mvorisek Jun 17, 2019

Author Contributor

PHP 7.3 uses newer POSIX regex engine and regexes like ~[\d-_]~ became invalid. The fixed regex may became invalid someday too, so I fixed it. - as character is safe to use only as regular range operator or when it is placed the most left or the most right in the character group.

@mvorisek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

PHP 7.3 uses newer POSIX regex engine and regexes like ~[\d-_]~ became invalid. The fixed regex may became invalid someday too, so I fixed it. - as character is safe to use only as regular range operator or when it is placed the most left or the most right in the character group.

@PierreRambaud

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2019

Oh yes, you're right, didn't think about 7.3 :P

@PierreRambaud
Copy link
Contributor

left a comment

I'm in favor of applying this change. But don't know if we can keep the 1.7.6.x target.

@mvorisek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

@PierreRambaud

I'm in favor of applying this change. But don't know if we can keep the 1.7.6.x target.

Opened a PR to develop branch, see #14223

@mvorisek mvorisek closed this Jun 17, 2019

@mvorisek mvorisek deleted the mvorisek:1.7.6.x branch Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.