Commit graph

230 commits

Author SHA1 Message Date
George Peter Banyard
90eeca2531 Convert some unknown encoding warnings to ValueErrors in ext/mbstring
Promotes only the warnings where the encoding comes only from a string.
Functions which accept an array of encodings will be fixed at a later stage.

Closes GH-5317
2020-03-31 16:34:18 +02:00
Christoph M. Becker
9e77d5a9da Fix #76999: mb_regex_set_options() return current options
When setting new options, `mb_regex_set_options()` is supposed to
return the *previous* options.
2020-03-27 10:34:16 +01:00
George Peter Banyard
c7094d8926 Fix mbstring regex variable types to correspond to Oniguruma
The beginning and ending of a Oniguruma Regex are stored in a OnigRegion (which is a typedef to the Oniguruma re_registers struct) as as int* therefore change the type from size_t to int

Closes GH-5196
2020-02-26 11:24:03 +01:00
Nikita Popov
22d2a80031 Merge branch 'PHP-7.4'
* PHP-7.4:
  Reset MBREX(search_re) in RSHUTDOWN
2020-01-29 16:05:47 +01:00
Nikita Popov
085371b299 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Reset MBREX(search_re) in RSHUTDOWN
2020-01-29 16:05:38 +01:00
Nikita Popov
560ff9725e Reset MBREX(search_re) in RSHUTDOWN
This is going to cause a segfault if reused in the next request.
To illustrate the issue, run these two scripts in sequence with
the built-in server:

// script1.php
mb_ereg_search_init('foobar');
mb_ereg_search('foo');

// script2.php
var_dump(mb_ereg_search_init("foobar"));
var_dump(mb_ereg_search_pos());
2020-01-29 16:05:11 +01:00
Nikita Popov
42e22a2d91 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix use of mb_ereg_search_getregs() after invalid pattern
2020-01-29 12:50:47 +01:00
Nikita Popov
b3f07afabc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix use of mb_ereg_search_getregs() after invalid pattern
2020-01-29 12:50:40 +01:00
Nikita Popov
392ad206a4 Fix use of mb_ereg_search_getregs() after invalid pattern
This segfaulted because we assumed that if there are matches,
there must be a regular expression as well.
2020-01-29 12:50:18 +01:00
Máté Kocsis
d1764ca330
Make error messages more consistent by fixing capitalization
Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
2020-01-17 14:52:46 +01:00
Máté Kocsis
aadd3aaed9
Use RETURN_THROWS() in various places 2020-01-03 21:10:24 +01:00
Máté Kocsis
345703724c
Use RETURN_THROWS() during ZPP in most of the extensions
Except for some bigger ones: reflection, sodium, spl
2019-12-31 11:46:11 +01:00
Christoph M. Becker
058fed6cd9 Just return on failing ZPP 2019-10-06 18:00:17 +02:00
Christoph M. Becker
013506779c Add missing zend_parse_parameters_none() 2019-10-06 17:56:40 +02:00
Nikita Popov
21e631e473 Merge branch 'PHP-7.4' 2019-10-06 10:07:57 +02:00
Nikita Popov
6623e7ac51 Add support for mbstring.regex_retry_limit
This is very similar to the existing mbstring.regex_stack_limit,
but for backtracking. The default value matches pcre.backtrack_limit.
Only used on libonig >= 2.8.0.
2019-10-06 10:06:33 +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
d2a1fe8462 Merge branch 'PHP-7.4' 2019-06-25 10:26:20 +02:00
Nikita Popov
46bad1d679 Fix region leak in mb_ereg_replace 2019-06-25 10:25:44 +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
Nikita Popov
47c74e780d Merge branch 'PHP-7.4' 2019-04-11 12:36:10 +02:00
Nikita Popov
cd8312a77e Merge branch 'PHP-7.3' into PHP-7.4 2019-04-11 12:36:01 +02:00
Nikita Popov
a61d24e4d8 Avoid onig match param unused variable warning 2019-04-11 12:35:24 +02:00
Stanislav Malyshev
63e0c22037 Merge branch 'PHP-7.4'
* PHP-7.4:
  Unfortunately, travis CI has old oniguruma library
  Update NEWS & UPGRADING
  Add fallbacks for older oniguruma versions
  Add mbstring.regex_stack_limit to php.ini-*
  Implement RF bug #72777 - ensure stack limits on mbstring functions.
2019-04-01 00:32:49 -07:00
Stanislav Malyshev
077ce33aa9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update NEWS & UPGRADING
  Add fallbacks for older oniguruma versions
  Add mbstring.regex_stack_limit to php.ini-*
  Implement RF bug #72777 - ensure stack limits on mbstring functions.
2019-04-01 00:05:36 -07:00
Stanislav Malyshev
bc8f292c05 Merge branch 'mb-limit-73' into PHP-7.3
* mb-limit-73:
  Add fallbacks for older oniguruma versions
  Add mbstring.regex_stack_limit to php.ini-*
  Implement RF bug #72777 - ensure stack limits on mbstring functions.
2019-04-01 00:00:14 -07:00
Stanislav Malyshev
e12c069d33 Add fallbacks for older oniguruma versions 2019-03-30 23:18:33 -07:00
Stanislav Malyshev
66c35b083b Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Validate subject encoding in mb_split and mb_ereg_match
  Validate pattern against mbregex encoding
  SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws
2019-03-28 00:42:56 -07:00
Stanislav Malyshev
402adc1df1 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Validate subject encoding in mb_split and mb_ereg_match
  Validate pattern against mbregex encoding
  SQLite3: add DEFENSIVE config for SQLite >= 3.26.0 as a mitigation strategy against potential security flaws
2019-03-28 00:35:22 -07:00
Yasuo Ohgaki
738016bd88 Implement RF bug #72777 - ensure stack limits on mbstring functions.
The patch creates new config: mbstring.regex_stack_limit, which
defaults to 100000.
2019-03-28 00:31:57 -07:00
Nikita Popov
0ecac37c40 Validate subject encoding in mb_split and mb_ereg_match
We were already validating the subject encoding in most functions,
but not these two.
2019-03-27 23:20:27 -07:00
Nikita Popov
40fe50daf6 Validate pattern against mbregex encoding
Oniguruma does not consistently perform this validation itself (at least
on older versions), so make sure we check pattern encoding validity on the
PHP side.
2019-03-27 23:19:46 -07:00
Nikita Popov
779b9bfe02 Merge branch 'PHP-7.4' 2019-02-11 15:00:52 +01:00
Nikita Popov
e91d8ac5f6 Add MB_ONIGURUMA_VERSION and use it in a version dependent test 2019-02-11 14:53:19 +01:00
Nikita Popov
d1c1481081 Unbundle oniguruma
And also switch detection over to pkg-config.
2019-02-11 14:53:19 +01:00
Nikita Popov
5702ce630b Merge branch 'PHP-7.4' 2019-02-11 12:32:38 +01:00
Nikita Popov
f5d2a30466 Validate subject encoding in mb_split and mb_ereg_match
We were already validating the subject encoding in most functions,
but not these two.
2019-02-11 12:31:59 +01:00
Nikita Popov
c9ab1078cc Merge branch 'PHP-7.4' 2019-02-11 12:12:54 +01:00
Nikita Popov
2e594265b8 Validate pattern against mbregex encoding
Oniguruma does not consistently perform this validation itself (at least
on older versions), so make sure we check pattern encoding validity on the
PHP side.
2019-02-11 12:10:40 +01:00
Peter Kokot
623911f993 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove local variables
2019-02-03 21:23:18 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Nikita Popov
4a4c68d90d Make mb_ereg(i) argument a normal string argument
Instead of manually handling the string conversion, use the standard
zpp mechanism.
2019-02-01 15:40:09 +01:00
Nikita Popov
06ed6b8978 Make mb_ereg_replace() pattern argument a string 2019-02-01 15:19:46 +01:00
Nikita Popov
ba5d2e6af3 Merge branch 'PHP-7.4' 2019-02-01 15:03:10 +01:00
Nikita Popov
e366ceebad Deprecate mb_ereg_replace with non-string pattern
I'm counting this towards the non-string needle deprecation from
https://wiki.php.net/rfc/deprecations_php_7_3. I wasn't aware that
mb_ereg_replace() is also affected by this issue. It's even more
ridiculous than usual here, because the integer is interpreted as
an ASCII codepoint, even though these are supposed to be multibyte
functions :(
2019-02-01 15:02:31 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Zeev Suraski
38c337f22e Remove year range from copyright notice 2019-01-30 11:00:23 +02:00
Nikita Popov
52a9325328 Remove 'e' modifier for mb_ereg_replace()
This was deprecated in PHP 7.1 through
https://wiki.php.net/rfc/deprecate_mb_ereg_replace_eval_option.
2019-01-29 13:04:20 +01:00
Nikita Popov
5e4c6dec12 Merge branch 'PHP-7.3' 2019-01-24 15:14:09 +01:00
Nikita Popov
3c98c2d0cb Fixed bug #77514 2019-01-24 15:13:49 +01:00