Commit Graph

1196 Commits

Author SHA1 Message Date
Ilija Tovilo
7f9ad4a83a
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Revert "Mangle PCRE regex cache key with JIT option"
2023-06-22 23:14:27 +02:00
Ilija Tovilo
4d91665f78
Revert "Mangle PCRE regex cache key with JIT option"
This reverts commit 466fc78d2c.
2023-06-22 23:13:37 +02:00
Ilija Tovilo
34a1a1bddb
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Mangle PCRE regex cache key with JIT option
2023-06-22 11:10:59 +02:00
Michael Voříšek
466fc78d2c
Mangle PCRE regex cache key with JIT option
Closes GH-11396
2023-06-22 11:08:54 +02:00
Ilija Tovilo
7c7698f754
Fix preg_replace_callback_array() pattern validation
Closes GH-11301
2023-05-24 13:42:16 +02:00
Ilija Tovilo
d1fc88c726
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect zval type_flags in preg_replace_callback_array() for immutable arrays
2023-03-31 14:42:35 +02:00
Ilija Tovilo
66ce205718
Fix incorrect zval type_flags in preg_replace_callback_array() for immutable arrays
The ZVAL_ARR macro always set the zval type_info to IS_ARRAY_EX, even if the
hash table is immutable. Since in preg_replace_callback_array() we can return
the passed array directly, and that passed array can be immutable, we need to
reset the type_flags to keep the VM from performing ref-counting on the array.

Fixes GH-10968
Closes GH-10970
2023-03-31 14:41:41 +02:00
George Peter Banyard
1ad59b32c2 Update INI validator and displayers depending on INI type
Closes GH-9451
2022-09-06 10:33:34 +01:00
Niklas Keller
f8b217a345
Fix pcre.jit on Apple Silicon
This backports https://github.com/zherczeg/sljit/pull/105. Relates to bug #80435, however, it doesn't solve the bus error on PHP 8.0, but PHP 8.1 builds fine now.

Closes GH-9279.
2022-08-31 14:22:44 +02:00
Máté Kocsis
b4ec3e9bc0
Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Michael Voříšek
60189aa96a
Skip locale tests /w musl libc (#9141) 2022-07-25 23:56:14 +01:00
Máté Kocsis
28944b8fbe
Declare ext/pcre constants in stubs (#9077) 2022-07-21 13:21:02 +02:00
Christoph M. Becker
32cceb75bf
Update to libpcre2 10.40 2022-07-11 19:45:46 +02:00
Ilija Tovilo
cda7e8f1ec
Replace another hard-coded line number 2022-06-23 16:48:17 +02:00
Ilija Tovilo
9bfdfcac8f
Replace more hard-coded line numbers 2022-06-23 16:28:42 +02:00
tobil4sk
5bb3e233db
Implement #77726: Allow null character in regex patterns
In 8b3c1a3, this was disallowed to fix #55856, which was a security
issue caused by the /e modifier. The fix that was made was the
"Easier fix" as described in the original report.

With this fix, pattern strings are no longer treated as null terminated,
so null characters can be placed inside and matched against with regex
patterns without security problems, so there is no longer a reason to
give the error. Allowing this is consistent with the behaviour of many
other languages, including JavaScript, and thanks to PCRE2[0], it does
not require manually escaping null characters. Now that we can avoid the
error here without the cost of escaping characters, there is really no
need anymore to stray here from the conventional behaviour.

Currently, null characters are still disallowed before the first
delimiter and in the options section at the end of a regex string, but
these error messages have been updated.

[0] Since PCRE2, pattern strings no longer have to be null terminated,
and raw null characters match as normal.

Closes GH-8114.
2022-06-17 19:30:44 +02:00
Tyson Andre
32e2d97a26
Allow internal functions to declare if they support compile-time evaluation, add functions. (#7780)
https://wiki.php.net/rfc/strtolower-ascii means that these functions no longer
depend on the current locale in php 8.2. Before that, this was unsafe to
evaluate at compile time.

Followup to GH-7506

Add strcmp/strcasecmp/strtolower/strtoupper functions

Add bin2hex/hex2bin and related functions

Update test of garbage collection using strtolower to use something else to create a refcounted string
2021-12-20 09:27:06 -05:00
Christoph M. Becker
c0d890e918
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:17:49 +01:00
Christoph M. Becker
60717fcd34
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:17:16 +01:00
Christoph M. Becker
816aa20391
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:15:20 +01:00
Christoph M. Becker
712fc54e85
Fix #74604: Out of bounds in php_pcre_replace_impl
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow; we make sure that this
doesn't happen by catering to the maximal overhead of a `zend_string`.

Closes GH-7597.
2021-11-29 19:12:55 +01:00
Christoph M. Becker
1f183792c1
Merge branch 'PHP-8.1'
* PHP-8.1:
  Update to PCRE2 10.39
2021-11-25 18:38:49 +01:00
Christoph M. Becker
6008a75f39
Update to PCRE2 10.39
We also apply an respective upstream fix[1].

[1] <d144199dfb>

Closes GH-7678.
2021-11-25 18:38:31 +01:00
Nikita Popov
2791afbf07 Merge branch 'PHP-8.1'
* PHP-8.1:
  Clarify that preg_match_all() cannot return null
2021-11-18 10:37:36 +01:00
Nikita Popov
3ec55d6cbf Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Clarify that preg_match_all() cannot return null
2021-11-18 10:37:18 +01:00
Nikita Popov
bc6ec0a109 Clarify that preg_match_all() cannot return null 2021-11-18 10:36:35 +01:00
Felipe Pena
e089a50f53 Add support for PCRE n modifier
Add support for /n (NO_AUTO_CAPTURE) modifier, which makes simple
`(xyz)` groups non-capturing.

Closes GH-7583.
2021-11-03 15:17:54 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Remi Collet
a6f5c2dc8b
fix for pcre2 10.38 2021-10-21 13:37:26 +02:00
Remi Collet
17aae1302e
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  fix for pcre2 10.38
  fix for pcre2 10.38
2021-10-21 13:34:28 +02:00
Remi Collet
dd61002676
fix for pcre2 10.38 2021-10-21 13:34:09 +02:00
Remi Collet
56495ac031
fix for pcre2 10.38 2021-10-21 13:33:35 +02:00
Christoph M. Becker
5356d06990
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-10-12 14:22:52 +02:00
Christoph M. Becker
845a67feb5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-10-12 14:21:09 +02:00
Christoph M. Becker
788a701e22
Fix #81424: PCRE2 10.35 JIT performance regression
We backport the respective upstream fix[1] to our bundled pcre2lib plus
the follow-up fix[2] for a functional regression.

[1] <dc5f966635>
[2] <e7af7efaa1>

Closes GH-7573.
2021-10-12 14:19:22 +02:00
Christoph M. Becker
34cd6cbfe0
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Revert "Fix #81424: PCRE2 10.35 JIT performance regression"
2021-10-05 11:52:32 +02:00
Christoph M. Becker
9523542733
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #81424: PCRE2 10.35 JIT performance regression"
2021-10-05 11:50:31 +02:00
Christoph M. Becker
a19f655b84
Revert "Fix #81424: PCRE2 10.35 JIT performance regression"
This reverts commit a2471383fe.

Fixing the performance regression, apparently fixes a functional
regression[1], so we revert for now.

[1] <https://github.com/PhilipHazel/pcre2/issues/21>

Closes GH-7556.
2021-10-05 11:49:04 +02:00
Christoph M. Becker
311b1de649
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-09-13 14:38:37 +02:00
Christoph M. Becker
12e79ddae4
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-09-13 14:35:49 +02:00
Christoph M. Becker
a2471383fe
Fix #81424: PCRE2 10.35 JIT performance regression
We backport the respective upstream fix[1] to our bundled pcre2lib.

[1] <dc5f966635>

Closes GH-7484.
2021-09-13 14:34:13 +02:00
Máté Kocsis
8e6e9838b0
Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Máté Kocsis
17ccabc6b6
Generate optimizer func info from stubs for ext/curl, ext/mysqli, ext/pcre (#7407) 2021-08-26 17:11:45 +02:00
Christoph M. Becker
e80dbd5f38
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81243: Too much memory is allocated for preg_replace()
2021-07-12 18:38:24 +02:00
Christoph M. Becker
5fb5a739e2
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81243: Too much memory is allocated for preg_replace()
2021-07-12 18:35:49 +02:00
Christoph M. Becker
a6b43086e6
Fix #81243: Too much memory is allocated for preg_replace()
Trimming a potentially over-allocated string appears to be reasonable,
so we drop the condition altogether.

We also re-allocate twice the size needed in the first place, and not
roughly tripple the size.

Closes GH-7231.
2021-07-12 18:33:55 +02:00
Brent Roose
909e13459c Fix typo "without-pcre-jit" 2021-07-06 11:47:00 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Anatol Belski
f7ab7951f1
pcre: Workaround bug #81101
The way to fix it is to disable certain match start optimizaions. The
observed performance impact appears negligible ATM, compared to the
functional regression revealed.

A possible side effect might occur if a pattern uses (*COMMIT) or
(*MARK), which is however not a very broadly used syntax in PHP. Still
this should be observed and handled by possibly adding a possibility to
reverse PCRE2_NO_START_OPTIMIZE on the user side.

One test shows a behavior change, where instead of int 0 the match
would produce an error and return false. Except strict comparison
is used, this should be acceptable.

Signed-off-by: Anatol Belski <ab@php.net>
(cherry picked from commit d188ca7688)
Signed-off-by: Anatol Belski <ab@php.net>
2021-06-19 15:25:17 +02:00
Anatol Belski
1a1d86d562 pcre: Workaround bug #81101
The way to fix it is to disable certain match start optimizaions. The
observed performance impact appears negligible ATM, compared to the
functional regression revealed.

A possible side effect might occur if a pattern uses (*COMMIT) or
(*MARK), which is however not a very broadly used syntax in PHP. Still
this should be observed and handled by possibly adding a possibility to
reverse PCRE2_NO_START_OPTIMIZE on the user side.

One test shows a behavior change, where instead of int 0 the match
would produce an error and return false. Except strict comparison
is used, this should be acceptable.

Signed-off-by: Anatol Belski <ab@php.net>
(cherry picked from commit d188ca7688)
Signed-off-by: Anatol Belski <ab@php.net>
2021-06-19 15:23:43 +02:00