From 15ba73cee3d48bc9d3b4ed54d06a8bb0841f93a5 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Fri, 27 Aug 2021 22:57:03 +0200 Subject: [PATCH] Add more tests for UTF-8 text conversion --- ext/mbstring/tests/utf8_mobile_encodings.phpt | 1 + ext/mbstring/tests/utf_encodings.phpt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ext/mbstring/tests/utf8_mobile_encodings.phpt b/ext/mbstring/tests/utf8_mobile_encodings.phpt index 918e897696d..21107ce5f08 100644 --- a/ext/mbstring/tests/utf8_mobile_encodings.phpt +++ b/ext/mbstring/tests/utf8_mobile_encodings.phpt @@ -31,6 +31,7 @@ $badUTF8 = array( // Multi-byte characters which end too soon and go to ASCII "\xDFA" => "\x00\x00\x00%\x00\x00\x00A", "\xEF\xBFA" => "\x00\x00\x00%\x00\x00\x00A", + "\xF0\xBFA" => "\x00\x00\x00%\x00\x00\x00A", "\xF0\xBF\xBFA" => "\x00\x00\x00%\x00\x00\x00A", // Multi-byte characters which end too soon and go to another MB char diff --git a/ext/mbstring/tests/utf_encodings.phpt b/ext/mbstring/tests/utf_encodings.phpt index 490048058d9..92a9f4f1f56 100644 --- a/ext/mbstring/tests/utf_encodings.phpt +++ b/ext/mbstring/tests/utf_encodings.phpt @@ -778,6 +778,7 @@ $invalid = array( // Multi-byte characters which end too soon and go to ASCII "\xDFA" => "\x00\x00\x00%\x00\x00\x00A", "\xEF\xBFA" => "\x00\x00\x00%\x00\x00\x00A", + "\xF0\xBFA" => "\x00\x00\x00%\x00\x00\x00A", "\xF0\xBF\xBFA" => "\x00\x00\x00%\x00\x00\x00A", // Multi-byte characters which end too soon and go to another MB char @@ -785,6 +786,11 @@ $invalid = array( "\xEF\xBF\xDF\xBF" => "\x00\x00\x00%\x00\x00\x07\xFF", "\xF0\xBF\xBF\xDF\xBF" => "\x00\x00\x00%\x00\x00\x07\xFF", + // Multi-byte characters which end too soon and go to a junk byte + // (Which isn't even valid to start a new character) + "\xF0\xBF\xBF\xFF" => "\x00\x00\x00%", + "\xF0\xBF\xFF" => "\x00\x00\x00%", + // Continuation bytes which appear outside of a MB char "\x80" => "\x00\x00\x00%", "A\x80" => "\x00\x00\x00A\x00\x00\x00%",