Commit graph

526 commits

Author SHA1 Message Date
Nikita Popov
6b73b2d6eb Check for empty string in mb_ord() 2017-08-04 22:20:05 +02:00
Nikita Popov
353f7bf461 Also check for invalid codepoints in mb_ord()
And return false in that case, instead of returning 0x3f...
2017-08-04 13:01:03 +02:00
Nikita Popov
e53162a32b Return false on invalid codepoint in mb_chr()
Instead of returning the encoding of the current substitution
character. This allows a robust check for the failure case. The
substitution character (especially the default of "?") is also
a valid output of mb_chr() for a valid input (for "?" that would be
0x3f), so it's a bad choice for an error value.
2017-08-03 22:36:42 +02:00
Nikita Popov
41e9ba6333 Always use Unicode codepoints in mb_ord() and mb_chr()
Previously mb_chr() had two different encoding-dependent behaviors:
 * For "Unicode-encodings" it took a Unicode codepoint and returned
   its encoded representation.
 * Otherwise it returned a big-endian binary encoding of the passed
   integer.

Now the input is always interpreted as a Unicode codepoint. If
a big-endian binary encoding is what you want, you don't need
mbstring to implement that.
2017-08-03 22:14:00 +02:00
Nikita Popov
fb9bf5b64b Revert/fix substitution character fallback
The introduced checks were not correct in two respects:
 * It was checked whether the source encoding of the string matches
   the internal encoding, while the actually relevant encoding is
   the *target* encoding.
 * Even if the correct encoding is used, the checks are still too
   conservative. Just because something is not a "Unicode-encoding"
   does not mean that it does not map any non-ASCII characters.

I've reverted the added checks and instead adjusted mbfl_convert
to first try to use the provided substitution character and if
that fails, perform the fallback to '?' at that point. This means
that any codepoint mapped in the target encoding should now be
correctly supported and anything else should fall back to '?'.
2017-08-03 21:53:59 +02:00
Nikita Popov
a8a9e93e9a Revert/fix mb_substitute_character() codepoint checks
The introduced checks did not treat "non-Unicode" encodings correctly,
because they treated the passed integer as encoded in the internal
encoding in that case, while in actuality the substitute character
is always a Unicode codepoint.

Additionally checking the codepoint against the internal encoding
is not correct in any case, because the substitution character must
be mapped in the *target* encoding of the conversion, which does
not necessarily coincide with the internal encoding (the internal
encoding is the default *source* encoding, not *target* encoding).

This reverts the checks back to simple range checks, but in a way
that still resolves #69079: Characters outside the Basic
Multilingual Plane are now accepted and Surrogate Codepoints are
rejected. A distinction between UTF-8 and non-UTF-8 encodings is
not made for surrogate checks (as in the original patch), as
surrogates are always illegal on their own. Specifying a surrogate
as substitution character would only make sense if you could
specify a substitution string with more than one character --
however we do not support that.
2017-08-03 21:12:41 +02:00
Nikita Popov
91240073ea Merge branch 'PHP-7.1' into PHP-7.2 2017-08-02 18:11:12 +02:00
Nikita Popov
63607375f5 Merge branch 'PHP-7.0' into PHP-7.1 2017-08-02 18:09:09 +02:00
Fabien Villepinte
2cc1cbf2f4 Fix Bug #75001: Wrong reflection on mb_eregi_replace 2017-08-02 18:08:42 +02:00
Nikita Popov
9af5b7f33d Fix use after free in mb_send_mail 2017-07-23 11:55:26 +02:00
Thomas Punt
9f08aff3fd Remove superfluous allocation checks around ZMM-based functions 2017-04-02 00:58:19 +02:00
Nikita Popov
edcabf6d07 Drop unnecessary allocator return value checks 2017-03-13 22:07:15 +01:00
Nikita Popov
a8239ff232 Deprecate mbstring.func_overload 2017-02-03 21:02:52 +01:00
Nikita Popov
2df9346e7f Deprecate mb_parse_str() without second argument 2017-02-03 18:52:57 +01:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Joe Watkins
c8aa6f3a9a
Merge branch 'pull-request/2268'
* pull-request/2268:
  Update copyright headers to 2017
2017-01-04 10:00:53 +00:00
Joe Watkins
f9a435a06d
Merge branch 'pull-request/1094'
* pull-request/1094:
  added php_mb_check_code_point for mb_substitute_character
  news entry for PR #1094
2017-01-04 06:57:34 +00:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Dmitry Stogov
3e9bb03a62 Removed IS_TYPE_IMMUTABLE (it's the same as COPYABLE & !REFCOUED) 2016-11-28 22:59:57 +03:00
Anatol Belski
b204b3abd1 further normalizations, uint vs uint32_t
fix merge mistake

yet one more replacement run
2016-11-26 17:29:01 +01:00
Anatol Belski
bfb9be9bd4 Merge branch 'PHP-7.1'
* PHP-7.1:
  remove TSRMLS_*
2016-11-22 00:33:29 +01:00
Anatol Belski
d61db8d602 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  remove TSRMLS_*
2016-11-22 00:32:42 +01:00
Anatol Belski
5e9b4c26a5 remove TSRMLS_* 2016-11-21 23:53:37 +01:00
Dmitry Stogov
222d22f3e1 Merge branch 'PHP-7.1'
* PHP-7.1:
  Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protect_memory=1)
2016-11-17 13:35:10 +03:00
Dmitry Stogov
a56bba14e0 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protect_memory=1)
2016-11-17 13:34:32 +03:00
Dmitry Stogov
a67637039f Prevent modification of immutable arrays (ext/mbstring/tests/bug26639.phpt failure with opcache.protect_memory=1) 2016-11-17 13:33:05 +03:00
Yasuo Ohgaki
7cb1be2ecd Use proper API 2016-10-16 07:29:33 +09:00
Yasuo Ohgaki
06b20d973a Fix test and cleanup code a little 2016-10-15 20:51:34 +09:00
Yasuo Ohgaki
4af00876f6 mb_check_encoding()/mb_convert_encoding() - Improve and add recursion detection. 2016-10-15 16:52:17 +09:00
Yasuo Ohgaki
6e530502d2 Implemented Bug #68776 mail() does not have mail header injection prevention for additional headers
(PR 2060)
2016-09-15 06:43:57 +09:00
Andrea Faulds
3cc9090101 Remove remaining zpp fallback code (master branch)
Follow-up to d690014bf3
2016-09-11 22:50:24 +01:00
Yasuo Ohgaki
8c26b0a6d2 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset
2016-09-08 13:33:07 +09:00
Yasuo Ohgaki
1ecf361c15 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset
2016-09-08 13:32:47 +09:00
Yasuo Ohgaki
379d9a1cfc Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset
2016-09-08 13:32:31 +09:00
Yasuo Ohgaki
8bbd0952e5 Fix Bug #72992 mbstring.internal_encoding doesn't inherit default_charset 2016-09-08 13:17:10 +09:00
Yasuo Ohgaki
98bc11b0cd Fix memleak. 2016-09-06 18:34:52 +09:00
Yasuo Ohgaki
96e59a200e Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed Bug #66964 mb_convert_variables() cannot detect recursion
2016-09-06 18:22:04 +09:00
Yasuo Ohgaki
2605ceeaca Added array parameter support to mb_convert_encoding() 2016-09-06 18:20:24 +09:00
Yasuo Ohgaki
012232b9a4 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed Bug #66964 mb_convert_variables() cannot detect recursion
2016-09-06 16:42:07 +09:00
Yasuo Ohgaki
6f1a52bfbb Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Fixed Bug #66964 mb_convert_variables() cannot detect recursion
2016-09-06 16:41:52 +09:00
Yasuo Ohgaki
a25f6f89cd Fixed Bug #66964 mb_convert_variables() cannot detect recursion 2016-09-06 16:05:34 +09:00
Yasuo Ohgaki
b651b96738 Allow array input for mb_check_encoding() 2016-09-02 14:18:34 +09:00
Christoph M. Becker
4c75b00025 Merge branch 'PHP-7.1' 2016-08-30 15:13:30 +02:00
Christoph M. Becker
ecdef60d00 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-30 15:12:49 +02:00
Christoph M. Becker
972302d2f0 Merge branch 'PHP-5.6' into PHP-7.0 2016-08-30 15:01:12 +02:00
Christoph M. Becker
2f10db36af Fix #66797: mb_substr only takes 32-bit signed integer
`from` and `len` are `long`, but get passed to mbfl_substr() which expects
`int`s. Therefore we clamp the values to avoid the undefined conversion
behavior.
2016-08-30 14:52:47 +02:00
Masaki Kagaya
c28a6f44bb add declaration of functions 2016-08-14 08:09:14 +09:00
Masaki Kagaya
f49a5a67cf delete duplicate functions 2016-08-14 06:29:23 +09:00
Yasuo Ohgaki
850a0b5fb6 Merge pull request #1098
Fix bug #69086 enhancement for mb_convert_encoding
2016-08-10 14:39:23 +09:00