Commit graph

585 commits

Author SHA1 Message Date
George Peter Banyard
1a2732f9a8 Use ZPP callable check for preg_replace_callback() $callback argument 2020-06-22 15:56:36 +02:00
twosee
83a77015ad Add helper APIs for maybe-interned string creation
Add ZVAL_CHAR/RETVAL_CHAR/RETURN_CHAR as a shortcut for using
ZVAL_INTERNED_STRING and ZSTR_CHAR.

Add zend_string_init_fast() as a helper for the empty string /
one char interned string / zend_string_init() pattern.

Also add corresponding ZVAL_STRINGL_FAST etc macros.

Closes GH-5684.
2020-06-08 15:31:52 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
Nikita Popov
2414b3d775 Ensure ctype_string is NULL for C locale
We already document that this is the case, but currently it's only
true if setlocale() has not been called. Make sure ctype_string is
always NULL, even with an explicit "C" locale call, so we can
more efficiently check whether we are in the "C" locale.

Closes GH-5542.
2020-05-07 21:26:13 +02:00
Nikita Popov
3f76947303 Rename locale_string to ctype_string
To make it more obvious that this only refers to the LC_CTYPE
locale.
2020-05-07 18:45:03 +02:00
Nikita Popov
4fb705a03d Add zend_string_concat2 API 2020-04-14 17:18:05 +02:00
Máté Kocsis
21cfa03f17
Generate function entries for another batch of extensions
Closes GH-5352
2020-04-05 21:15:30 +02:00
Máté Kocsis
01b266aac4
Improve error messages of various extensions
Closes GH-5278
2020-03-23 18:59:04 +01:00
Nicolas Oelgart
aa79a22d32 Add preg_last_error_msg() function
Provides the last PCRE error as a human-readable message, similar
to functionality existing in other extensions, such as
json_last_error_msg().

Closes GH-5185.
2020-02-25 10:26:03 +01:00
Nikita Popov
5cf9710ba8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79257
2020-02-11 17:32:49 +01:00
Nikita Popov
3a51530963 Fixed bug #79257
Replace an existing entry for a given name only if we have a match.
2020-02-11 17:31:48 +01:00
Nikita Popov
d2befbc17d Merge branch 'PHP-7.4'
* PHP-7.4:
  PCRE: Only remember valid UTF-8 if start offset zero
  PCRE: Check whether start offset is on char boundary
2020-02-07 17:02:49 +01:00
Nikita Popov
cd5591a28d PCRE: Only remember valid UTF-8 if start offset zero
PCRE only validates the string starting from the start offset
(minus maximum look-behind, but let's ignore that), so we can
only remember that the string is fully valid UTF-8 is the original
start offset is zero.
2020-02-07 17:01:39 +01:00
Nikita Popov
c9e78e6d33 PCRE: Check whether start offset is on char boundary
We need not just the whole string to be UTF-8, but the start
position to be on a character boundary as well. Check this by
looking for a continuation byte.
2020-02-07 16:49:28 +01:00
Nikita Popov
065224190d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79188
2020-02-05 11:21:34 +01:00
Nikita Popov
e30f52b919 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79188
2020-02-05 11:21:25 +01:00
Nikita Popov
13bfa9f5ac Fixed bug #79188 2020-02-05 11:18:46 +01:00
Máté Kocsis
9099dbd961
Use RETURN_THROWS() after zend_type_error() 2020-01-01 14:23:21 +01:00
Christoph M. Becker
e7e15450ef Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #78853: preg_match() may return integer > 1
2019-11-22 19:30:43 +01:00
Christoph M. Becker
cfb643ca2b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78853: preg_match() may return integer > 1
2019-11-22 19:29:11 +01:00
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
ea6d22cfad Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix php_pcre_mutex_free()
2019-11-07 14:32:03 +01:00
Nikita Popov
e19f0e86dc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix php_pcre_mutex_free()
2019-11-07 14:31:55 +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
571a3bfc6c Merge branch 'PHP-7.4' 2019-10-08 16:14:19 +02:00
Nikita Popov
68b26ff8cf Merge branch 'PHP-7.3' into PHP-7.4 2019-10-08 16:14:06 +02: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
647b1c7fcf Remove most uses of ZEND_PARSE_PARAMETERS_END_EX()
As ZPP now throws, it makes no sense to specify an explicit return
value.
2019-10-07 10:02:18 +02:00
Nikita Popov
43358cc7b6 Merge branch 'PHP-7.4' 2019-10-04 16:04:42 +02:00
Nikita Popov
01b3cc4dee Merge branch 'PHP-7.3' into PHP-7.4 2019-10-04 16:04:34 +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
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Nikita Popov
8c927442b4 Merge branch 'PHP-7.4' 2019-08-13 14:54:57 +02:00
Nikita Popov
201729840c Mark PCRE locale key as local persistent 2019-08-13 14:49:59 +02:00
Nikita Popov
228bae7d74 Use TypeError for preg_replace type check
This is a type violation warning, and as such should use TypeError
in PHP 8.
2019-08-11 14:28:10 +02:00
Stephen Reay
66b750d07e Add stubs for PCRE extension
Closes GH-4501.
2019-08-11 12:46:42 +02:00
Sjon Hortensius
05752d3acf Ref #77388: Don't pass BAD_ESCAPE_IS_LITERAL
This option is considered dangerous and unwanted. To allow for more
graceful migration don't error on now ignored X modifier.

Closes GH-4430.
2019-07-18 10:52:27 +02:00
Dmitry Stogov
e3d35b6434 Split destructor 2019-07-04 13:07:47 +03:00
Nikita Popov
ad1b62fca7 Merge branch 'PHP-7.3' into PHP-7.4 2019-06-17 13:31:04 +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
Nikita Popov
51fb8dc422 Add specialized pair construction API
Closes GH-3990.
2019-06-11 12:29:55 +02:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Dmitry Stogov
e188e4170f Use ZEND_TRY_ASSIGN_REF_... macros for arguments passed to internal function by reference 2019-04-24 18:28:29 +03:00
Peter Kokot
e06836a1a3 Remove checks for locale.h, setlocale, localeconv
The `<loccale.h>` header file, setlocale, and localeconv are part of the
standard C89 [1] and on current systems can be used unconditionally.

Since PHP 7.4 requires at least C89 or greater, the `HAVE_LOCALE_H`,
`HAVE_SETLOCALE`, and `HAVE_LOCALECONV` symbols defined by Autoconf in
configure.ac [2] can be ommitted and simplifed.

The bundled libmagic (file) has also been patched already in version
5.35 and up in upstream location so when it will be patched also in
php-src the check for locale.h header is still left in the configure.ac
and in windows headers definition file.

[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.4
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4

Omit the bundled libmagic files
2019-04-07 18:32:54 +02:00
Christoph M. Becker
2733420f82 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77827: preg_match does not ignore \r in regex flags
2019-03-31 13:35:50 +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
a9b01b60d8 Make PCRE cache per-request on CLI
There will only be one request on the CLI SAPI, so there is no
advantage to having a persistent PCRE cache. Using a non-persistent
cache allows us to use arbitrary strings as cache keys.
2019-03-26 10:10:41 +01:00