mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Respect OFFSET_CAPTURE when padding preg_match_all() results
This issue was mentioned in bug #73948. The PREG_PATTERN_ORDER padding was performed without respecting the PREF_OFFSET_CAPTURE flag, which resulted in unmatched subpatterns being either null or [null, -1] depending on where they occur. Now they will always be [null, -1], consistent with other usages.
This commit is contained in:
parent
2783670daa
commit
f53e7394eb
3 changed files with 80 additions and 16 deletions
|
@ -1290,7 +1290,11 @@ matched:
|
||||||
*/
|
*/
|
||||||
if (count < num_subpats) {
|
if (count < num_subpats) {
|
||||||
for (; i < num_subpats; i++) {
|
for (; i < num_subpats; i++) {
|
||||||
if (unmatched_as_null) {
|
if (offset_capture) {
|
||||||
|
add_offset_pair(
|
||||||
|
&match_sets[i], NULL, 0, PCRE2_UNSET,
|
||||||
|
NULL, unmatched_as_null);
|
||||||
|
} else if (unmatched_as_null) {
|
||||||
add_next_index_null(&match_sets[i]);
|
add_next_index_null(&match_sets[i]);
|
||||||
} else {
|
} else {
|
||||||
add_next_index_str(&match_sets[i], ZSTR_EMPTY_ALLOC());
|
add_next_index_str(&match_sets[i], ZSTR_EMPTY_ALLOC());
|
||||||
|
|
|
@ -94,8 +94,12 @@ array (
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
1 =>
|
1 =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
@ -106,18 +110,34 @@ array (
|
||||||
0 => '4',
|
0 => '4',
|
||||||
1 => 3,
|
1 => 3,
|
||||||
),
|
),
|
||||||
3 => NULL,
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
2 =>
|
2 =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => '2',
|
0 => '2',
|
||||||
1 => 1,
|
1 => 1,
|
||||||
),
|
),
|
||||||
2 => NULL,
|
2 =>
|
||||||
3 => NULL,
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -120,8 +120,12 @@ array (
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'a' =>
|
'a' =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
@ -132,11 +136,19 @@ array (
|
||||||
0 => '4',
|
0 => '4',
|
||||||
1 => 3,
|
1 => 3,
|
||||||
),
|
),
|
||||||
3 => NULL,
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
1 =>
|
1 =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
@ -147,29 +159,57 @@ array (
|
||||||
0 => '4',
|
0 => '4',
|
||||||
1 => 3,
|
1 => 3,
|
||||||
),
|
),
|
||||||
3 => NULL,
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'b' =>
|
'b' =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => '2',
|
0 => '2',
|
||||||
1 => 1,
|
1 => 1,
|
||||||
),
|
),
|
||||||
2 => NULL,
|
|
||||||
3 => NULL,
|
|
||||||
),
|
|
||||||
2 =>
|
2 =>
|
||||||
array (
|
array (
|
||||||
0 => NULL,
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
2 =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
1 =>
|
1 =>
|
||||||
array (
|
array (
|
||||||
0 => '2',
|
0 => '2',
|
||||||
1 => 1,
|
1 => 1,
|
||||||
),
|
),
|
||||||
2 => NULL,
|
2 =>
|
||||||
3 => NULL,
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
|
3 =>
|
||||||
|
array (
|
||||||
|
0 => NULL,
|
||||||
|
1 => -1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue