summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 15:31:37 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 15:34:23 +1100
commit902d145793959ce0347b202303f8cb34223e6b04 (patch)
tree85d737a13511c01446626fa97cec97ecdfee0503 /tests
parentbe782a0b0313d3b23473b6fd08e08ffea20156be (diff)
downloadfengari-902d145793959ce0347b202303f8cb34223e6b04.tar.gz
fengari-902d145793959ce0347b202303f8cb34223e6b04.tar.bz2
fengari-902d145793959ce0347b202303f8cb34223e6b04.zip
src/defs.js: Check for invalid continuation bytes
Diffstat (limited to 'tests')
-rw-r--r--tests/defs.js26
1 files changed, 25 insertions, 1 deletions
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");
});