|
| 1 | +// extra error cases copied from wpt/encoding/textdecoder-fatal.any.js |
| 2 | +// commit sha: 7c9f867 |
| 3 | +// link: https://github.com/web-platform-tests/wpt/commit/7c9f8674d9809731e8919073d957d6233f6e0544 |
| 4 | + |
| 5 | +export const utf8WebPlatformSpecTests = [ |
| 6 | + { encoding: 'utf-8', input: [0xff], name: 'invalid code' }, |
| 7 | + { encoding: 'utf-8', input: [0xc0], name: 'ends early' }, |
| 8 | + { encoding: 'utf-8', input: [0xe0], name: 'ends early 2' }, |
| 9 | + { encoding: 'utf-8', input: [0xc0, 0x00], name: 'invalid trail' }, |
| 10 | + { encoding: 'utf-8', input: [0xc0, 0xc0], name: 'invalid trail 2' }, |
| 11 | + { encoding: 'utf-8', input: [0xe0, 0x00], name: 'invalid trail 3' }, |
| 12 | + { encoding: 'utf-8', input: [0xe0, 0xc0], name: 'invalid trail 4' }, |
| 13 | + { encoding: 'utf-8', input: [0xe0, 0x80, 0x00], name: 'invalid trail 5' }, |
| 14 | + { encoding: 'utf-8', input: [0xe0, 0x80, 0xc0], name: 'invalid trail 6' }, |
| 15 | + { encoding: 'utf-8', input: [0xfc, 0x80, 0x80, 0x80, 0x80, 0x80], name: '> 0x10ffff' }, |
| 16 | + { encoding: 'utf-8', input: [0xfe, 0x80, 0x80, 0x80, 0x80, 0x80], name: 'obsolete lead byte' }, |
| 17 | + |
| 18 | + // Overlong encodings |
| 19 | + { encoding: 'utf-8', input: [0xc0, 0x80], name: 'overlong U+0000 - 2 bytes' }, |
| 20 | + { encoding: 'utf-8', input: [0xe0, 0x80, 0x80], name: 'overlong U+0000 - 3 bytes' }, |
| 21 | + { encoding: 'utf-8', input: [0xf0, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 4 bytes' }, |
| 22 | + { encoding: 'utf-8', input: [0xf8, 0x80, 0x80, 0x80, 0x80], name: 'overlong U+0000 - 5 bytes' }, |
| 23 | + { |
| 24 | + encoding: 'utf-8', |
| 25 | + input: [0xfc, 0x80, 0x80, 0x80, 0x80, 0x80], |
| 26 | + name: 'overlong U+0000 - 6 bytes' |
| 27 | + }, |
| 28 | + |
| 29 | + { encoding: 'utf-8', input: [0xc1, 0xbf], name: 'overlong U+007f - 2 bytes' }, |
| 30 | + { encoding: 'utf-8', input: [0xe0, 0x81, 0xbf], name: 'overlong U+007f - 3 bytes' }, |
| 31 | + { encoding: 'utf-8', input: [0xf0, 0x80, 0x81, 0xbf], name: 'overlong U+007f - 4 bytes' }, |
| 32 | + { encoding: 'utf-8', input: [0xf8, 0x80, 0x80, 0x81, 0xbf], name: 'overlong U+007f - 5 bytes' }, |
| 33 | + { |
| 34 | + encoding: 'utf-8', |
| 35 | + input: [0xfc, 0x80, 0x80, 0x80, 0x81, 0xbf], |
| 36 | + name: 'overlong U+007f - 6 bytes' |
| 37 | + }, |
| 38 | + |
| 39 | + { encoding: 'utf-8', input: [0xe0, 0x9f, 0xbf], name: 'overlong U+07ff - 3 bytes' }, |
| 40 | + { encoding: 'utf-8', input: [0xf0, 0x80, 0x9f, 0xbf], name: 'overlong U+07ff - 4 bytes' }, |
| 41 | + { encoding: 'utf-8', input: [0xf8, 0x80, 0x80, 0x9f, 0xbf], name: 'overlong U+07ff - 5 bytes' }, |
| 42 | + { |
| 43 | + encoding: 'utf-8', |
| 44 | + input: [0xfc, 0x80, 0x80, 0x80, 0x9f, 0xbf], |
| 45 | + name: 'overlong U+07ff - 6 bytes' |
| 46 | + }, |
| 47 | + |
| 48 | + { encoding: 'utf-8', input: [0xf0, 0x8f, 0xbf, 0xbf], name: 'overlong U+ffff - 4 bytes' }, |
| 49 | + { encoding: 'utf-8', input: [0xf8, 0x80, 0x8f, 0xbf, 0xbf], name: 'overlong U+ffff - 5 bytes' }, |
| 50 | + { |
| 51 | + encoding: 'utf-8', |
| 52 | + input: [0xfc, 0x80, 0x80, 0x8f, 0xbf, 0xbf], |
| 53 | + name: 'overlong U+ffff - 6 bytes' |
| 54 | + }, |
| 55 | + |
| 56 | + { encoding: 'utf-8', input: [0xf8, 0x84, 0x8f, 0xbf, 0xbf], name: 'overlong U+10ffff - 5 bytes' }, |
| 57 | + { |
| 58 | + encoding: 'utf-8', |
| 59 | + input: [0xfc, 0x80, 0x84, 0x8f, 0xbf, 0xbf], |
| 60 | + name: 'overlong U+10ffff - 6 bytes' |
| 61 | + }, |
| 62 | + |
| 63 | + // UTf-16 surrogates encoded as code points in UTf-8 |
| 64 | + { encoding: 'utf-8', input: [0xed, 0xa0, 0x80], name: 'lead surrogate' }, |
| 65 | + { encoding: 'utf-8', input: [0xed, 0xb0, 0x80], name: 'trail surrogate' }, |
| 66 | + { encoding: 'utf-8', input: [0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80], name: 'surrogate pair' } |
| 67 | +]; |
0 commit comments