From 902d145793959ce0347b202303f8cb34223e6b04 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 15:31:37 +1100 Subject: src/defs.js: Check for invalid continuation bytes --- tests/defs.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/defs.js b/tests/defs.js index b00fda0..244e31b 100644 --- a/tests/defs.js +++ b/tests/defs.js @@ -58,9 +58,33 @@ test('to_jsstring', function (t) { }); test('to_jsstring fails on invalid unicode', function (t) { - t.plan(1); + t.plan(7); t.throws(function() { defs.to_jsstring([165]); }, "non-utf8 char"); + + t.throws(function() { + defs.to_jsstring([208, 60]); + }, "invalid continuation byte"); + + t.throws(function() { + defs.to_jsstring([225, 60, 145]); + }, "invalid continuation byte"); + + t.throws(function() { + defs.to_jsstring([225, 145, 60]); + }, "invalid continuation byte"); + + t.throws(function() { + defs.to_jsstring([242, 60, 145, 145]); + }, "invalid continuation byte"); + + t.throws(function() { + defs.to_jsstring([242, 145, 60, 145]); + }, "invalid continuation byte"); + + t.throws(function() { + defs.to_jsstring([242, 145, 145, 60]); + }, "invalid continuation byte"); }); -- cgit v1.2.3-70-g09d2