Commit graph

249 commits

Author SHA1 Message Date
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
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.
2021-01-14 12:11:11 +01:00
Nikita Popov
5582490bf2 Normalize mb_ereg() return value
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.
2020-10-13 20:40:55 +02:00
George Peter Banyard
0444158529 Promote some warnings in MBString Regexes
Closes GH-5341
2020-09-09 14:55:07 +02:00
Alex Dowad
62317d592f Remove redundant includes from mbstring (and make sure correct config.h is used)
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.
2020-08-31 23:17:58 +02:00
Alex Dowad
a64241b540 Remove unused functions from mbstring
- 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
2020-08-31 23:16:57 +02:00
Máté Kocsis
ac0da090ae
Fix UNKNOWN default values in ext/mbstring and ext/gd
Closes GH-5598
2020-07-28 17:06:25 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Christoph M. Becker
3516a9c8f0 Replace ISO_8859-* with ISO8859-* aliases for MBString
We also remove the mbregex ISO 8859 aliases with underscores.
2020-06-30 18:43:40 +02:00
Nikita Popov
bbe74a6e3a Merge branch 'PHP-7.4' 2020-06-16 14:32:33 +02:00
Nikita Popov
3f2f36d5d4 Fix non-default syntax in mb_ereg_search() 2020-06-16 14:31:29 +02:00
George Peter Banyard
68164f40ce Fix [-Wundef] warning in MBString extension 2020-05-16 15:31:20 +02:00
George Peter Banyard
2a4c81f1ee Fix [-Wjump-misses-init] in php_mbregex.c by adding an inner scope 2020-04-18 14:52:48 +02:00
George Peter Banyard
3eba187b15 Refactor and remove dead code in mb_ereg(i)_replace
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.
2020-04-10 17:56:05 +02:00
George Peter Banyard
73455778d4 Cache MBFL encoding for Oniguruma regex functions.
Closes GH-5355
2020-04-09 13:48:55 +02:00
George Peter Banyard
577de174de Use ZEND_NUM_ARGS() macro instead of custom variable
Also why on earth would someone do this?
2020-04-02 22:40:00 +02:00
Nikita Popov
11f0e1d1cb Move encoding fetching out of php_mb_convert_encoding() 2020-03-31 21:47:55 +02:00
George Peter Banyard
daf45f68d2 Use explicit helper 2020-03-31 20:27:10 +02:00
George Peter Banyard
affc5a024a Encoding argument is always MBREX(current_mbctype) 2020-03-31 20:27:10 +02:00
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