-
Notifications
You must be signed in to change notification settings - Fork 8.2k
pcre: minor refactoring and improvements #23928
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
Draft
Girgias
wants to merge
7
commits into
php:master
Choose a base branch
from
Girgias:pcre-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d46d0b
pcre: minor clean-up of PHP_MINFO_FUNCTION(pcre)
Girgias 7d33c58
pcre: add comment for when constant was defined
Girgias 91ce53d
pcre: drop some ZPP tests
Girgias db4dfee
pcre: add some tests for disabled PCRE features
Girgias 68e69a6
pcre: improve error message for \K in lookarounds
Girgias 3d76c81
pcre: block callout syntax in pattern compilation if PCRE2 lib suppor…
Girgias 2aeffed
pcre: drop ifdef around PCRE2_UCP
Girgias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --TEST-- | ||
| PCRE2 callout feature is not supported. | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PCRE_VERSION_MAJOR >= 10 && PCRE_VERSION_MINOR >= 45) { | ||
| die("skip callout feature is disable in PCRE2 10.45 and above"); | ||
| } | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $subject = 'hello'; | ||
| $pattern = '/a(?C1)b(?C2)c/'; | ||
|
|
||
| var_dump(preg_match($pattern, $subject)); | ||
|
|
||
| ?> | ||
| --EXPECT-- | ||
| int(0) | ||
|
Comment on lines
+6
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --TEST-- | ||
| PCRE2 callout feature is not supported and disabled if pcre2 lib permits it. | ||
| --SKIPIF-- | ||
| <?php | ||
| if (!(PCRE_VERSION_MAJOR >= 10 && PCRE_VERSION_MINOR >= 45)) { | ||
| die("skip needs 10.45 or above"); | ||
| } | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $subject = 'hello'; | ||
| $pattern = '/a(?C1)b(?C2)c/'; | ||
|
|
||
| var_dump(preg_match($pattern, $subject)); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Warning: preg_match(): Compilation failed: using callouts is disabled by the application at offset 4 in %s on line %d | ||
| bool(false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --TEST-- | ||
| Disabled PCRE2 regex compilation features. | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $subject = 'hello'; | ||
| $patterns = [ | ||
| '/\u/', // Unknown unicode escape sequence | ||
| '/\C/u', // \C in unicode | ||
| '/a(?=b\K)/', // \K in look around | ||
| ]; | ||
|
|
||
| foreach ($patterns as $pattern) { | ||
| var_dump(preg_match($pattern, $subject)); | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Warning: preg_match(): Compilation failed: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u at offset 2 in %s on line %d | ||
| bool(false) | ||
|
|
||
| Warning: preg_match(): Compilation failed: using \C is incompatible with the 'u' modifier at offset 2 in %s on line %d | ||
| bool(false) | ||
|
|
||
| Warning: preg_match(): Compilation failed: \K is not allowed in lookarounds at offset 8 in %s on line %d | ||
| bool(false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you either need to guard it or update config0.m4 min. version check (was added for 10.38).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I might try and upgrade the minimal version to 10.40.