summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
Commit message (Collapse)AuthorAgeFilesLines
* Make convert_to_*_ex simple aliases of convert_to_*Nikita Popov2021-01-141-1/+1
| | | | | | | | | | | | | Historically, the _ex variants separated the zval first, if a conversion was necessary. This distinction no longer makes sense since PHP 7. The only difference that was still left is that _ex checked whether the type is the same first, but the usage of these macros did not actually distinguish on whether such an inlined check is valuable or not in a given context. Also drop the unused convert_to_explicit_type macros.
* Normalize mb_ereg() return valueNikita Popov2020-10-131-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mb_ereg()/mb_eregi() currently have an inconsistent return value based on whether the $matches parameter is passed or not: > Returns the byte length of the matched string if a match for > pattern was found in string, or FALSE if no matches were found > or an error occurred. > > If the optional parameter regs was not passed or the length of > the matched string is 0, this function returns 1. Coupling this behavior to the $matches parameter doesn't make sense -- we know the match length either way, there is no technical reason to distinguish them. However, returning the match length is not particularly useful either, especially due to the need to convert 0-length into 1-length to satisfy "truthy" checks. We could always return 1, which would kind of match the behavior of preg_match() -- however, preg_match() actually returns the number of matches, which is 0 or 1 for preg_match(), while false signals an error. However, mb_ereg() returns false both for no match and for an error. This would result in an odd 1|false return value. The patch canonicalizes mb_ereg() to always return a boolean, where true indicates a match and false indicates no match or error. This also matches the behavior of the mb_ereg_match() and mb_ereg_search() functions. This fixes the default value integrity violation in PHP 8. Closes GH-6331.
* Promote some warnings in MBString RegexesGeorge Peter Banyard2020-09-091-37/+37
| | | | Closes GH-5341
* Remove redundant includes from mbstring (and make sure correct config.h is used)Alex Dowad2020-08-311-3/+1
| | | | | | | | | | | Very interesting... it turns out that when Valgrind support was enabled, `#include "config.h"` from within mbstring was actually including the file "config.h" from Valgrind, and not the one from mbstring!! This is because -I/usr/include/valgrind was added to the compiler invocation _before_ -Iext/mbstring/libmbfl. Make sure we actually include the file which was intended.
* Remove unused functions from mbstringAlex Dowad2020-08-311-7/+0
| | | | | | | | | | | | | | | | - mbfl_buffer_converter_reset - mbfl_buffer_converter_strncat - mbfl_buffer_converter_getbuffer - mbfl_oddlen - mbfl_filter_output_pipe_flush - mbfl_memory_device_output2 - mbfl_memory_device_output4 - mbfl_is_support_encoding - mbfl_buffer_converter_feed2 - _php_mb_regex_globals_dtor - mime_header_encoder_feed - mime_header_decoder_feed - mbfl_convert_filter_feed
* Fix UNKNOWN default values in ext/mbstring and ext/gdMáté Kocsis2020-07-281-20/+15
| | | | Closes GH-5598
* Remove proto comments from C filesMax Semenik2020-07-061-32/+16
| | | | Closes GH-5758
* Replace ISO_8859-* with ISO8859-* aliases for MBStringChristoph M. Becker2020-06-301-15/+15
| | | | We also remove the mbregex ISO 8859 aliases with underscores.
* Merge branch 'PHP-7.4'Nikita Popov2020-06-161-5/+5
|\
| * Fix non-default syntax in mb_ereg_search()Nikita Popov2020-06-161-5/+5
| |
* | Fix [-Wundef] warning in MBString extensionGeorge Peter Banyard2020-05-161-2/+2
| |
* | Fix [-Wjump-misses-init] in php_mbregex.c by adding an inner scopeGeorge Peter Banyard2020-04-181-0/+2
| |
* | Refactor and remove dead code in mb_ereg(i)_replaceGeorge Peter Banyard2020-04-101-39/+8
| | | | | | | | | | | | We do not support the 'e' option anymore. Merged together code which would emit an error if this option is present. This also makes it clearer that the whole branch in the replacement section supporting this option is never hit, thus removed.
* | Cache MBFL encoding for Oniguruma regex functions.George Peter Banyard2020-04-091-26/+13
| | | | | | | | Closes GH-5355
* | Use ZEND_NUM_ARGS() macro instead of custom variableGeorge Peter Banyard2020-04-021-5/+4
| | | | | | | | Also why on earth would someone do this?
* | Move encoding fetching out of php_mb_convert_encoding()Nikita Popov2020-03-311-6/+13
| |
* | Use explicit helperGeorge Peter Banyard2020-03-311-9/+7
| |
* | Encoding argument is always MBREX(current_mbctype)George Peter Banyard2020-03-311-7/+8
| |
* | Convert some unknown encoding warnings to ValueErrors in ext/mbstringGeorge Peter Banyard2020-03-311-2/+2
| | | | | | | | | | | | | | 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
* | Fix #76999: mb_regex_set_options() return current optionsChristoph M. Becker2020-03-271-3/+5
| | | | | | | | | | When setting new options, `mb_regex_set_options()` is supposed to return the *previous* options.
* | Fix mbstring regex variable types to correspond to OnigurumaGeorge Peter Banyard2020-02-261-2/+6
| | | | | | | | | | | | 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
* | Merge branch 'PHP-7.4'Nikita Popov2020-01-291-0/+1
|\ \ | |/ | | | | | | * PHP-7.4: Reset MBREX(search_re) in RSHUTDOWN
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-01-291-0/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Reset MBREX(search_re) in RSHUTDOWN
| | * Reset MBREX(search_re) in RSHUTDOWNNikita Popov2020-01-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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());
* | | Merge branch 'PHP-7.4'Nikita Popov2020-01-291-3/+5
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix use of mb_ereg_search_getregs() after invalid pattern
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-01-291-3/+5
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix use of mb_ereg_search_getregs() after invalid pattern
| | * Fix use of mb_ereg_search_getregs() after invalid patternNikita Popov2020-01-291-3/+5
| | | | | | | | | | | | | | | This segfaulted because we assumed that if there are matches, there must be a regular expression as well.
* | | Make error messages more consistent by fixing capitalizationMáté Kocsis2020-01-171-1/+1
| | | | | | | | | | | | Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
* | | Use RETURN_THROWS() in various placesMáté Kocsis2020-01-031-1/+1
| | |
* | | Use RETURN_THROWS() during ZPP in most of the extensionsMáté Kocsis2019-12-311-12/+12
| | | | | | | | | | | | Except for some bigger ones: reflection, sodium, spl
* | | Just return on failing ZPPChristoph M. Becker2019-10-061-6/+6
| | |
* | | Add missing zend_parse_parameters_none()Christoph M. Becker2019-10-061-0/+8
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-061-1/+8
|\ \ \ | |/ /
| * | Add support for mbstring.regex_retry_limitNikita Popov2019-10-061-1/+8
| | | | | | | | | | | | | | | | | | 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.
* | | Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-251-2/+0
| | | | | | | | | | | | Closes GH-4732.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-06-251-1/+1
|\ \ \ | |/ /
| * | Fix region leak in mb_ereg_replaceNikita Popov2019-06-251-1/+1
| | |
| * | Allow exceptions in __toString()Nikita Popov2019-06-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-04-111-1/+1
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-04-111-1/+1
| |\ \ | | |/
| | * Avoid onig match param unused variable warningNikita Popov2019-04-111-1/+1
| | |
* | | Merge branch 'PHP-7.4'Stanislav Malyshev2019-04-011-5/+41
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | * 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.
| * | Merge branch 'PHP-7.3' into PHP-7.4Stanislav Malyshev2019-04-011-5/+41
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | * 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.
| | * Merge branch 'mb-limit-73' into PHP-7.3Stanislav Malyshev2019-04-011-5/+41
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | * 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.
| | | * Add fallbacks for older oniguruma versionsStanislav Malyshev2019-03-301-1/+13
| | | |
| | | * Implement RF bug #72777 - ensure stack limits on mbstring functions.Yasuo Ohgaki2019-03-281-5/+29
| | | | | | | | | | | | | | | | | | | | The patch creates new config: mbstring.regex_stack_limit, which defaults to 100000.
| | * | Merge branch 'PHP-7.2' into PHP-7.3Stanislav Malyshev2019-03-281-3/+17
| | |\ \ | | | |/ | | |/| | | | | | | | | | | | | | | | | * 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
| | | * Merge branch 'PHP-7.1' into PHP-7.2Stanislav Malyshev2019-03-281-3/+17
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| | | | * Validate subject encoding in mb_split and mb_ereg_matchNikita Popov2019-03-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | We were already validating the subject encoding in most functions, but not these two.
| | | | * Validate pattern against mbregex encodingNikita Popov2019-03-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.