summaryrefslogtreecommitdiff
path: root/lib/js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2019-03-10 15:37:40 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2019-03-10 15:37:40 -0400
commit43666c47b550904e5573e28fab6ba9d2c51ddcd3 (patch)
tree068ddaa87a05640016f84023eb8ddcdb494df753 /lib/js
parentc2833576dc32ec143c5f4180c7688962eeec5e05 (diff)
JavaScript string subscripting should raise out-of-bounds exceptions
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/urweb.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 1c296fe1..749e5056 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -2493,6 +2493,8 @@ function id(x) { return x; }
function sub(s, i) {
var ch = undefined;
iterateString(s, function(c, idx) { if (idx == i) { ch = c; return false; }});
+ if (ch == undefined)
+ er("String index " + i + " out of bounds")
return ch;
}
function suf(s, i) {