-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flush filter during non-strict encoding detection
If we reach the end of the string without reducing to a single encoding, then we should flush to check whether the last character is incomplete.
- Loading branch information
Showing
2 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
ext/mbstring/tests/mb_detect_encoding_incomplete_sequence.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--TEST-- | ||
mb_detect_encoding() with incomplete trailing sequence | ||
--EXTENSIONS-- | ||
mbstring | ||
--FILE-- | ||
<?php | ||
|
||
// Even in non-strict mode, this should detect as ISO-8859-1. When the end of the string is | ||
// reached neither have illegal characters and would be picked based on score. However, flushing | ||
// the string will disqualify UTF-8 due to illegal characters. | ||
var_dump(mb_detect_encoding("A\xC2", ["UTF-8", "ISO-8859-1"])); | ||
|
||
?> | ||
--EXPECT-- | ||
string(10) "ISO-8859-1" |