Commit graph

526 commits

Author SHA1 Message Date
Christoph M. Becker
e1da72bdf1 Fix #78853: preg_match() may return integer > 1
Commit 54ebebd[1] optimized the match loop, but for this case it has
been overlooked, that we must only loop if we're doing global matching.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=54ebebd686255c5f124af718c966edb392782d4a>
2019-11-22 19:26:26 +01:00
Nikita Popov
6dcc0b859f Fix php_pcre_mutex_free()
We should only set the mutex to NULL if we actually freed it.
Due to missing braces non-main threads may currently set it to
NULL first.
2019-11-07 14:31:19 +01:00
Nikita Popov
736af5f660 Merge branch 'PHP-7.2' into PHP-7.3 2019-10-08 16:13:17 +02:00
Sergei Turchanov
a8f60ac9dd Add pcre_get_compiled_regex_cache_ex() with local_aware flag
A new function `pcre_get_compiled_regex_cache_ex()` is introduced,
which allows to compile regexp pattern using the "C" locale instead
of a current locale.

This will be needed to replace setlocale() usage in fileinfo,
which is not thread-safe.
2019-10-08 16:11:55 +02:00
Nikita Popov
1d6e9da743 Improve diagnostic on PCRE JIT mmap failure
Print a more informative message that indicates that this is
likely a permission issue, and also indicate that pcre.jit=0
can be used to work around it.

Also automatically disable the JIT, so that this message is
only shown once.

See bug #78630.
2019-10-04 16:03:38 +02:00
Nikita Popov
11b354dd54 Merge branch 'PHP-7.2' into PHP-7.3 2019-06-17 13:30:56 +02:00
Nikita Popov
03db04c3ab Accept null for preg_quote delimiter argument
Related to bug #78163.
2019-06-17 13:30:15 +02:00
Christoph M. Becker
d8b7728b0e Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77827: preg_match does not ignore \r in regex flags
2019-03-31 13:33:21 +02:00
Christoph M. Becker
88460c017a Fix #77827: preg_match does not ignore \r in regex flags 2019-03-31 13:31:54 +02:00
Nikita Popov
661bce47ae Fixed bug #76127
Per documentation, and consistent with other preg functions, we
should return false if an error occurred.
2019-03-19 13:57:39 +01:00
Nikita Popov
b1deb98c42 Fixed bug #77338
Set preg_options to 0 in php_pcre_get_compiled_regex(_ex). These
options are intended to be passed to pcre2_match. However, we do
not have any flags that actually need to be set during matching
(all relevant flags are set during compilation), and the preg_flags
value is used for PHP-specific flags instead.

This parameter should be removed entirely in master to avoid confusion.
2018-12-26 17:11:27 +01:00
Anatol Belski
ef1269d5c1 Fixed bug #77193 Infinite loop in preg_replace_callback
Don't return preallocated match data more than once in nested calls.
2018-12-01 10:24:06 +01:00
Anatol Belski
68c34ce0dc Make a copy unconditionally 2018-09-09 10:42:53 +02:00
Anatol Belski
9278be148e Fix memory leak in pcre cache 2018-09-09 10:38:36 +02:00
Anatol Belski
c6ddd45650 Fixed bug #76850 Exit code mangled by set locale/preg_match 2018-09-08 21:35:23 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
5be44312f8 Removed redundand code 2018-07-19 15:47:15 +03:00
Dmitry Stogov
54ebebd686 Matching loops optimization 2018-07-19 15:28:31 +03:00
Dmitry Stogov
b81d712961 Micro optimizations 2018-07-19 11:19:28 +03:00
Dmitry Stogov
1820f2f2f3 Reorder conditions 2018-07-18 17:46:48 +03:00
Dmitry Stogov
29f942b3d0 Move "/e" modifier check into regex compiler 2018-07-18 16:35:17 +03:00
Dmitry Stogov
5d60651165 Merge "no_utf_check" and "g_notempty" into single "options". 2018-07-18 16:10:41 +03:00
Anatol Belski
81eb8e7507 Mark conditions unexpected 2018-07-11 18:05:28 +02:00
Anatol Belski
0630e3bc03 Reduce error buffer size
120 bytes is ample, the doc says.
2018-07-05 17:24:38 +02:00
Anatol Belski
ff8f2710f6 Check return value of pcre2_maketables() 2018-06-29 19:15:38 +02:00
Anatol Belski
aa92d42018 If there's no setlocale, char tables are not used 2018-06-22 17:31:26 +02:00
Anatol Belski
8b58b2aac6 Don't discard char tables just generated 2018-06-22 15:18:39 +02:00
Anatol Belski
684ce24eec Improve locale character tables handling and reduce pattern cache size
If a locale other than C is active, character tables are saved into the
compile context. Every compiled pattern will have a pointer to the
character table, that was present in the context at the time of the
pattern compilation. Thus, the cache entries don't need to carry char
tables pointer, which reduces their size to 8 bytes on 64-bit. Instead,
the generated character tables are tracked in a separate HashTable. If a
character table was generated before, it'll be assigned to the compile
context when the locale changes. Otherwise a new char table will be
generated and cached.
2018-06-22 14:45:29 +02:00
Anatol Belski
bb2f1a6830 Fixed bug #76514 Regression in preg_match makes it fail with PREG_JIT_STACKLIMIT_ERROR
Looks like some patterns might require more stack for JIT execution. It
is a regression, as the same pattern was passing using JIT.
2018-06-22 11:05:30 +02:00
Christoph M. Becker
71d16feebb Fix #76512: \w no longer includes unicode characters
The migration from PCRE to PCRE2 missed to rename once occurrence of
`PCRE_UCP` to `PCRE2_UCP`.  We fix that.  We also revert the changes to
bug52971.phpt which had been incorrectly made in commit a5bc5ae[1].

[1] <http://git.php.net/?p=php-src.git;a=commit;h=a5bc5aed71f7a15f14f33bb31b8e17bf5f327e2d>
2018-06-21 22:45:08 +02:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Anatol Belski
28132878f2 Reduce var scope 2018-02-17 13:02:49 +01:00
Dmitry Stogov
cfee682802 Fixed possible incorrect "mark" usage 2018-01-09 10:30:00 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Dmitry Stogov
856ad54f45 Use zend_hash_find() instead of zend_hash_find_ptr() to avoid double check 2017-12-27 13:25:21 +03:00
Michael Moravec
84235344f9 Fixed bug #75355: preg_quote() does not quote # control character 2017-12-16 17:34:41 +01:00
Anatol Belski
57f33b4ce2 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix yet one data race in PCRE
2017-12-06 16:04:22 +01:00
Anatol Belski
1b29dc0b1c Fix yet one data race in PCRE
PCRE 8.x initializes the pattern compiler on demand during the first
pcre_study call. It could be worse, but since the compiled patterns are
cached, the locking impact is minimal. PCRE 10.x always compiles the
pattern and thread sanitizer doesn't complain about the compiler
initialization, thus the newer PCRE version seems to be unafected.
2017-12-06 15:59:21 +01:00
Anatol Belski
9c8ffbf1af Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix use after free revealed by phpdbg
2017-12-05 18:35:16 +01:00
Anatol Belski
d4af204637 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix use after free revealed by phpdbg
2017-12-05 18:34:39 +01:00
Anatol Belski
092fd44474 Fix use after free revealed by phpdbg 2017-12-05 18:32:32 +01:00
Anatol Belski
9cca85ff07 Fixed bug #75601 Thread race in PCRE JIT support 2017-12-05 17:41:08 +01:00
Anatol Belski
75a2ee7f7b Fixed bug #75601 Thread race in PCRE JIT support 2017-12-05 17:40:00 +01:00
Anatol Belski
31b2b14a71 Fixed bug #75601 Thread race in PCRE JIT support 2017-12-05 17:38:18 +01:00
Anatol Belski
c029bd3342 Fix macro name 2017-11-21 20:27:17 +01:00
Anatol Belski
54e7b0a6f7 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed #75539 and #74183 - preg_last_error not returning error code after error
2017-11-21 20:15:30 +01:00
Anatol Belski
f6b0d365a7 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed #75539 and #74183 - preg_last_error not returning error code after error
2017-11-21 20:11:21 +01:00
Anatol Belski
f5c0754f6e Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed #75539 and #74183 - preg_last_error not returning error code after error
2017-11-21 20:10:49 +01:00
Nester
8fdef981ef Fixed #75539 and #74183 - preg_last_error not returning error code after error 2017-11-21 20:10:18 +01:00