summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-05-12 17:14:13 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-05-12 17:14:13 -0400
commitaefc3accf262f17945ec53764d5828707ccab316 (patch)
tree7b127a36fbb5427c13faebb5351d949d7feea79d
parent1c9d518d630dbd8f5d622d8be7693d116a577c66 (diff)
Escape less-than in JavaScript strings
-rw-r--r--src/c/urweb.c12
-rw-r--r--tests/treeDyn.ur18
-rw-r--r--tests/treeDyn.urp4
-rw-r--r--tests/treeDyn.urs1
4 files changed, 35 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 4dae4c3d..1ca45836 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -1380,6 +1380,10 @@ uw_Basis_string uw_Basis_jsifyString(uw_context ctx, uw_Basis_string s) {
strcpy(s2, "\\\\");
s2 += 2;
break;
+ case '<':
+ strcpy(s2, "\\074");
+ s2 += 4;
+ break;
default:
if (isprint((int)c) || c >= 128)
*s2++ = c;
@@ -1417,6 +1421,10 @@ uw_Basis_string uw_Basis_jsifyChar(uw_context ctx, uw_Basis_char c1) {
strcpy(s2, "\\\\");
s2 += 2;
break;
+ case '<':
+ strcpy(s2, "\\074");
+ s2 += 4;
+ break;
default:
if (isprint((int)c) || c >= 128)
*s2++ = c;
@@ -1451,6 +1459,10 @@ uw_Basis_string uw_Basis_jsifyString_ws(uw_context ctx, uw_Basis_string s) {
strcpy(s2, "\\\\");
s2 += 2;
break;
+ case '<':
+ strcpy(s2, "\\074");
+ s2 += 4;
+ break;
default:
if (isprint((int)c) || c >= 128)
*s2++ = c;
diff --git a/tests/treeDyn.ur b/tests/treeDyn.ur
new file mode 100644
index 00000000..1d58cca5
--- /dev/null
+++ b/tests/treeDyn.ur
@@ -0,0 +1,18 @@
+table t : {Id : int, Parent : option int}
+
+fun recurse (root : option int) =
+ queryX' (SELECT * FROM t WHERE {eqNullable' (SQL t.Parent) root})
+ (fn r =>
+ children <- recurse (Some r.T.Id);
+ (*s <- source False;*)
+ return <xml>
+ <dyn signal={(*v <- signal s;
+ if v then*)
+ return <xml><b>HI</b>{children}<b>BYE</b></xml>
+ (*else
+ return <xml/>*)}/>
+ </xml>)
+
+fun main () =
+ x <- recurse None;
+ return <xml><body>{x}</body></xml>
diff --git a/tests/treeDyn.urp b/tests/treeDyn.urp
new file mode 100644
index 00000000..231bad2f
--- /dev/null
+++ b/tests/treeDyn.urp
@@ -0,0 +1,4 @@
+database dbname=treeDyn
+sql treeDyn.sql
+
+treeDyn
diff --git a/tests/treeDyn.urs b/tests/treeDyn.urs
new file mode 100644
index 00000000..901d6bf2
--- /dev/null
+++ b/tests/treeDyn.urs
@@ -0,0 +1 @@
+val main : {} -> transaction page