Commit graph

13 commits

Author SHA1 Message Date
Niels Dossche
b2a54bc6af Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11300: license issue: restricted unicode license headers
2023-07-01 22:03:08 +02:00
Niels Dossche
297fec099e Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11300: license issue: restricted unicode license headers
2023-07-01 21:56:40 +02:00
Niels Dossche
ee42621ff6 Fix GH-11300: license issue: restricted unicode license headers
Closes GH-11572.
2023-07-01 21:55:21 +02:00
Alex Dowad
f337c92050 Test mb_strlen for all text encodings supported by mbstring
When combining all the CJK encoding conversion code in a single file,
I combined some redundant mblen tables. This check will help to ensure
that all the mblen tables are correct.
2023-05-20 21:27:48 -07:00
Yuya Hamada
e0e587cdb8 mbstring: Do not stop when mbstring test failed
I way want to confirm different on mbstring PHP 8.1 or newer and
PHP 8.0 or older, but when I port to PHP 8.0 from PHP 8.1 or newer
phpt files, it stopped die() function when test failed. I want to
make a list, so I don't want to stop it.

If you execute full test, set $testFailedLimit to -1 in
encoding_tests.inc.
2022-12-19 16:29:17 +02:00
Alex Dowad
3c73225125 New internal interface for fast text conversion in mbstring
When converting text to/from wchars, mbstring makes one function call
for each and every byte or wchar to be converted. Typically, each of
these conversion functions contains a state machine, and its state has
to be restored and then saved for every single one of these calls.
It doesn't take much to see that this is grossly inefficient.

Instead of converting one byte or wchar on each call, the new
conversion functions will either fill up or drain a whole buffer of
wchars on each call. In benchmarks, this is about 3-10× faster.

Adding the new, faster conversion functions for all supported legacy
text encodings still needs some work. Also, all the code which uses
the old-style conversion functions needs to be converted to use the
new ones. After that, the old code can be dropped. (The mailparse
extension will also have to be fixed up so it will still compile.)
2021-12-21 08:33:11 +02:00
Alex Dowad
ff85ed8adc Fix conversion of EUC-TW text (and add test suite)
- Treat text which ends abruptly in the middle of a multi-byte
  character as erroneous.
- Don't allow ASCII control characters to appear in the middle of a
  multi-byte character.
- If an illegal byte appears in the middle of a multi-byte character,
  go back to the initial state rather than trying to finish the
  multi-byte character.
- There was a bug in the file with the conversion tables, which set the
  'maximum codepoint which can be converted using table A2' using the
  size of table A1, not table A2. This meant that several hundred
  Unicode codepoints which should have been able to be converted to
  EUC-TW were flagged as erroneous instead.
- When a sequence which cannot possibly be a prefix of a valid
  multi-byte character is found, immediately flag it as an error, rather
  than waiting to read more bytes first.
- Allow characters in CNS-11643 plane 1 to be encoded as 4-byte
  sequences (although they can also be encoded as 2-byte sequences).
  This is allowed by the standard for EUC-TW text.
2021-06-29 12:25:21 +02:00
Alex Dowad
b489c1bc4d Bugfixes for findInvalidChars (helper for mbstring test suite) 2020-11-25 19:52:19 +02:00
Alex Dowad
d1d50c2b7a Test EUC-JP and Shift-JIS more thoroughly
Previously, the unit tests for these text encodings covered all mappings
from legacy -> Unicode, and all _reversible_ mappings from Unicode -> legacy.
However, we should also test the few Unicode -> legacy mappings which
are not reversible.
2020-11-11 11:18:58 +02:00
Alex Dowad
3eb8828d1a Fix issues with mbstring encoding tests
I made some mistakes on this code, which meant that not everything which
should be tested was actually being tested.
2020-11-09 13:45:16 +02:00
Alex Dowad
b18b9c9ef6 Test cases for mbstring encodings are less repetitive 2020-11-02 21:31:05 +02:00
Alex Dowad
831abe2d90 Add test suite for CP1252 encoding
Also remove a bogus test (bug62545.phpt) which wrongly assumed that all invalid
characters in CP1251 and CP1252 should map to Unicode 0xFFFD (REPLACEMENT
CHARACTER).

mbstring has an interface to specify what invalid characters should be
replaced with; it's called `mb_substitute_character`. If a user wants to see
the Unicode 'replacement character', they can specify that using
`mb_substitute_character`. But if they specify something else, we should
follow that.
2020-10-30 22:13:27 +02:00
Alex Dowad
84c180d88b Add test suite for ISO-8859-x encoding verification and conversion 2020-10-16 22:25:48 +02:00