Skip to content

Commit 181e6e2

Browse files
committed
test: more encoding mistakes tests
1 parent 51f3ea9 commit 181e6e2

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

tests/encoding/mistakes.test.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,40 @@ describe('Common implementation mistakes', () => {
271271
check([0, 255], [128, 255], [129, 48], [129, 255], [254, 48], [254, 255], [255, 0], [255, 255])
272272
})
273273

274-
describe('Push back ASCII characters on errors', () => {
274+
describe('Replacement, push back ASCII characters', () => {
275275
const vectors = {
276276
big5: [
277+
[[0x80], '\uFFFD'], // Node.js fails
277278
[[0x81, 0x40], '\uFFFD@'], // WebKit fails: https://bugs.webkit.org/show_bug.cgi?id=304238. Chrome and Firefox are correct. Node.js fails (see below)
278279
[[0x83, 0x5c], '\uFFFD\x5C'], // Node.js fails: https://github.com/nodejs/node/issues/40091. Chrome and Firefox are correct. WebKit fails (see above)
279-
[[0x87, 0x87, 0x40], '\uFFFD@'], // Chrome fails: https://issues.chromium.org/issues/467727340. Firefox and WebKit are correct
280-
[[0x81, 0x81], '\uFFFD'], // Chrome fails: https://issues.chromium.org/issues/467727340. Firefox and WebKit are correct
280+
[[0x87, 0x87, 0x40], '\uFFFD@'], // Chrome fails: https://issues.chromium.org/issues/467727340. Firefox and WebKit are correct. iconv/whatwg-encoding fails
281+
[[0x81, 0x81], '\uFFFD'], // Chrome fails: https://issues.chromium.org/issues/467727340. Firefox and WebKit are correct. iconv/whatwg-encoding fails
281282
],
282283
'iso-2022-jp': [
283284
[[0x1b, 0x24], '\uFFFD$'], // Node.js fails on this. Chrome, Firefox and Safari are correct
284-
[[0x1b, 0x24, 0x40, 0x1b, 0x24], '\uFFFD\uFFFD'], // Last 0x24 is invalid on both attemtps. Chrome fails on this
285+
[[0x1b, 0x24, 0x40, 0x1b, 0x24], '\uFFFD\uFFFD'], // Last 0x24 is invalid on both attemtps. Chrome, WebKit, text-encoding fail on this. Firefox, Deno, Servo are correct
286+
],
287+
gb18030: [
288+
[[0xa0, 0x30, 0x2b], '\uFFFD0+'],
289+
[[0x81, 0x31], '\uFFFD'], // iconv / whatwg-encoding fails
290+
],
291+
'euc-jp': [
292+
[[0x80], '\uFFFD'], // Node.js fails
293+
[[0x8d, 0x8d], '\uFFFD\uFFFD'], // coherence
294+
[[0x8e, 0x8e], '\uFFFD'], // iconv / whatwg-encoding, text-encoding fail
295+
],
296+
'euc-kr': [
297+
[[0x80], '\uFFFD'], // Node.js fails
298+
[[0xad, 0xad], '\uFFFD'], // iconv / whatwg-encoding fails
299+
[[0x41, 0xc7, 0x41], 'A\uFFFDA'], // text-encoding fails. Chrome, Firefox, Webkit are correct
300+
],
301+
shift_jis: [
302+
[[0x85, 0x85], '\uFFFD'], // iconv / whatwg-encoding fails
285303
],
286-
gb18030: [[[0xa0, 0x30, 0x2b], '\uFFFD0+']],
287-
gbk: [[[0xa0, 0x30, 0x2b], '\uFFFD0+']],
288304
// TODO: more vectors?
289305
}
290306

291-
// vectors.gbk = vectors.gb18030
307+
vectors.gbk = vectors.gb18030
292308
for (const [encoding, list] of Object.entries(vectors)) {
293309
describe(encoding, () => {
294310
for (const fatal of [false, true]) {

0 commit comments

Comments
 (0)