OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <title>Character Decoding - Invalid Trail Bytes</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
3 <script src="resources/char-decoding-utils.js"></script> | 5 <script src="resources/char-decoding-utils.js"></script> |
4 <script> | 6 <script> |
5 | 7 |
6 description("Test encoding behavior for sequences with invalid trail bytes"); | |
7 | |
8 // UTF-8 codec emits replacement characters | 8 // UTF-8 codec emits replacement characters |
9 testDecode('UTF-8', '%C3%22', 'U+FFFD/U+0022'); | 9 testDecode('UTF-8', '%C3%22', 'U+FFFD/U+0022'); |
10 testDecode('UTF-8', '%E2%22', 'U+FFFD/U+0022'); | 10 testDecode('UTF-8', '%E2%22', 'U+FFFD/U+0022'); |
11 testDecode('UTF-8', '%E2%A0%22', 'U+FFFD/U+FFFD/U+0022'); | 11 testDecode('UTF-8', '%E2%A0%22', 'U+FFFD/U+FFFD/U+0022'); |
12 testDecode('UTF-8', '%F0%90%80%22', 'U+FFFD/U+FFFD/U+FFFD/U+0022'); | 12 testDecode('UTF-8', '%F0%90%80%22', 'U+FFFD/U+FFFD/U+FFFD/U+0022'); |
13 | 13 |
14 // When a trail byte is in the ASCII range and lead+trail does not | 14 // When a trail byte is in the ASCII range and lead+trail does not |
15 // encode a character, the ASCII trail byte has to be added back to | 15 // encode a character, the ASCII trail byte has to be added back to |
16 // the stream. Otherwise, lead+trail as a whole is turned to U+FFFD. | 16 // the stream. Otherwise, lead+trail as a whole is turned to U+FFFD. |
17 testDecode('EUC-KR', '%C4%22', 'U+FFFD/U+0022'); | 17 testDecode('EUC-KR', '%C4%22', 'U+FFFD/U+0022'); |
(...skipping 29 matching lines...) Expand all Loading... |
47 testDecode('Shift_JIS', '%85%7B', 'U+FFFD/U+007B'); | 47 testDecode('Shift_JIS', '%85%7B', 'U+FFFD/U+007B'); |
48 testDecode('Shift_JIS', '%87%7B', 'U+FFFD/U+007B'); | 48 testDecode('Shift_JIS', '%87%7B', 'U+FFFD/U+007B'); |
49 testDecode('Shift_JIS', '%98%7E', 'U+FFFD/U+007E'); | 49 testDecode('Shift_JIS', '%98%7E', 'U+FFFD/U+007E'); |
50 testDecode('Shift_JIS', '%FC%5B', 'U+FFFD/U+005B'); | 50 testDecode('Shift_JIS', '%FC%5B', 'U+FFFD/U+005B'); |
51 | 51 |
52 // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28141#c4 | 52 // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=28141#c4 |
53 // We're different from the encoding spec as of 2015-03-18. | 53 // We're different from the encoding spec as of 2015-03-18. |
54 testDecode('shift_jis', '%EB%9F', 'U+FFFD'); | 54 testDecode('shift_jis', '%EB%9F', 'U+FFFD'); |
55 | 55 |
56 </script> | 56 </script> |
OLD | NEW |