Skip to content

Commit

Permalink
Add more tests for UTF-8 text conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdowad committed Aug 30, 2021
1 parent 51a32cc commit 15ba73c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/mbstring/tests/utf8_mobile_encodings.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ext/mbstring/tests/utf_encodings.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,19 @@ $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
"\xDF\xDF\xBF" => "\x00\x00\x00%\x00\x00\x07\xFF",
"\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%",
Expand Down

0 comments on commit 15ba73c

Please sign in to comment.