Commit graph

826 commits

Author SHA1 Message Date
Anatol Belski
0bc4cf901c Fix unsigned comparisons 2018-02-17 13:02:50 +01:00
Nikita Popov
d7fe32500e Match strpos() behavior with mbstring.func_overload
mb_strpos() specifically emulates strpos() behavior when function
overloading is enabled. However, the condition was not changed
when strpos() behavior changed in PHP 7.
2018-02-05 20:58:15 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Dmitry Stogov
b864e6b58c Move constants into read-only data segment 2017-12-15 01:55:00 +03:00
Dmitry Stogov
83e495e0fd Move constants into read-only data segment 2017-12-14 22:14:36 +03:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Dmitry Stogov
185478d07e Use cheaper SEPARATE macros 2017-12-07 22:35:17 +03:00
Dmitry Stogov
6a9d2b2190 Cleanup type conversion 2017-12-07 19:24:55 +03:00
Joe Watkins
21e4ab1977
Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix proto documents for new global functions
2017-11-06 07:24:51 +00:00
Tyson Andre
5cdf37e603
Fix proto documents for new global functions
See NEWS and UPGRADING (or arginfo/implementation) for details.
2017-11-06 07:24:42 +00:00
Dmitry Stogov
3b2e858304 Overlad functions once in MINIT (instead of on each requestr in RINIT) 2017-11-02 14:09:06 +03:00
Nikita Popov
251c1b1a44 Fix invalid read in mb_ord() 2017-10-28 16:44:32 +02:00
Dmitry Stogov
9cf87aa196 Avoid HashTable allocations for empty arrays (using zend_empty_array). 2017-10-24 17:27:31 +03:00
Peter Kokot
a57de26c3d Refactor mbstring READMEs 2017-10-08 17:51:02 +02:00
Dmitry Stogov
45ee78e040 mb_convert_variables() refactored to use simple recursion.
Fixed incorrect recursion protection (previous implementation kept protection flag or apply counter in non-zero state).
2017-10-06 12:08:55 +03:00
Dmitry Stogov
cb9d81ef4f Refactored recursion pretection 2017-10-06 01:34:50 +03:00
Dmitry Stogov
44e0b79ac6 Refactored array creation API. array_init() and array_init_size() are converted into macros calling zend_new_array(). They are not functions anymore and don't return any values. 2017-09-20 02:25:56 +03:00
Nikita Popov
fea7957d08 Optimize mb_chr()
By avoiding an unnecessary copy between a string an zend_string.
2017-08-04 22:38:54 +02:00
Nikita Popov
f24db7686e Optimize mb_ord()
Don't perform a full encoding conversion into UCS4-BE, instead only
perform an input conversion into a wchar device.
2017-08-04 22:22:58 +02:00
Nikita Popov
840b77c02e Merge branch 'PHP-7.2' 2017-08-04 22:20:11 +02:00
Nikita Popov
6b73b2d6eb Check for empty string in mb_ord() 2017-08-04 22:20:05 +02:00
Nikita Popov
4e4ec31e2e Merge branch 'PHP-7.2' 2017-08-04 13:02:44 +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
5caf05f6c5 Merge branch 'PHP-7.2' 2017-08-03 22:41:15 +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
c98714f19e Merge branch 'PHP-7.2' 2017-08-03 21:57:35 +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
3d948d77d1 Merge branch 'PHP-7.2' 2017-08-03 21:17:26 +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
94fe629992 Merge branch 'PHP-7.2' 2017-08-02 18:11:17 +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
582a65b06f Implement full case mapping
Implement full case mapping according to SpecialCasing.txt and
also full case folding according to CaseFolding.txt (F). There
are a number of caveats:

* Only language-agnostic and unconditional full case mapping
  is implemented. The only language-agnostic conditional case
  mapping rule relates to Greek sigma in final position
  (Final_Sigma). Correctly handling this requires both arbitrary
  lookahead and lookbehind, which would require some larger
  changes to how the case mapping is implemented. This is a
  possible future extension.
* The only language-specific handling that is implemented is
  for Turkish dotted/undotted Is, if the ISO-8859-9 encoding
  is used. This matches the previous behavior and makes sure
  that no codepoints not supported by the encoding are
  produced. A future extension would be to also handle the
  Turkish mappings specified by SpecialCasing.txt based on
  the mbfl internal language.
* Full case folding is implemented, but case-insensitive mb_*
  operations continue to use simple case folding. The reason is
  that full case folding of the haystack string may change the
  position at which a match occurred. This would have to be
  mapped back into the position in the original string.
* mb_convert_case() exposes both the full and the simple case
  mapping / folding, where full is the default. The constants
  are:

   * MB_CASE_LOWER (used by mb_strtolower)
   * MB_CASE_UPPER (used by mb_strtolower)
   * MB_CASE_TITLE
   * MB_CASE_FOLD
   * MB_CASE_LOWER_SIMPLE
   * MB_CASE_UPPER_SIMPLE
   * MB_CASE_TITLE_SIMPLE
   * MB_CASE_FOLD_SIMPLE (used by case-insensitive operations)
2017-07-28 12:32:50 +02:00
Nikita Popov
9ac7c1e71d Use case-folding for case insensitive comparisons
Instead of using lowercasing.
2017-07-28 12:32:50 +02:00
Nikita Popov
f56b0afe6e Avoid some unnecessary mbfl_strlen() calculations 2017-07-28 12:32:50 +02:00
Anatol Belski
13a2629005 size_t fixes 2017-07-25 19:03:33 +02:00
Nikita Popov
445e13b149 Add MBFL_SUBSTR_TO_END mode to mbfl_substr
This takes the substr from the offset to the end of the string.
This avoids pointless searching for the end position and also
saves us a length calculation in the strstr family of functions.
2017-07-23 23:17:12 +02:00
Nikita Popov
bff11c382e Remove more obsolete length checks 2017-07-23 19:09:36 +02:00
Anatol Belski
78944bdfc6 remove cast 2017-07-23 17:38:28 +02:00
Anatol Belski
6809be2090 fix warnings and datatype
ident
2017-07-23 17:36:10 +02:00
Nikita Popov
b8ed74ce77 Merge branch 'PHP-7.2' 2017-07-23 11:55:46 +02:00
Nikita Popov
bd63c0f5b3 Fix bug #73528 2017-07-23 11:55:43 +02:00
Nikita Popov
80463579ce Remove confusing null checks in mb_send_mail
These are required parameters, they cannot be missing.
2017-07-23 11:55:43 +02:00
Nikita Popov
9af5b7f33d Fix use after free in mb_send_mail 2017-07-23 11:55:26 +02:00
Anatol Belski
4fbd7ccba2 touch yet more places for datatypes 2017-07-23 00:47:24 +02:00
Anatol Belski
61784bcb71 sync libmbfl allocator with the size_t changes 2017-07-22 23:53:00 +02:00