changeset 1457:aa2398e58306

Escape less-than in JavaScript strings
author Adam Chlipala <adam@chlipala.net>
date Thu, 12 May 2011 17:14:13 -0400
parents d674fb9499c4
children bd6b03bc6333
files src/c/urweb.c tests/treeDyn.ur tests/treeDyn.urp tests/treeDyn.urs
diffstat 4 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/urweb.c	Fri May 06 20:51:40 2011 -0430
+++ b/src/c/urweb.c	Thu May 12 17:14:13 2011 -0400
@@ -1380,6 +1380,10 @@
       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 @@
     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 @@
       strcpy(s2, "\\\\");
       s2 += 2;
       break;
+    case '<':
+      strcpy(s2, "\\074");
+      s2 += 4;
+      break;
     default:
       if (isprint((int)c) || c >= 128)
         *s2++ = c;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/treeDyn.ur	Thu May 12 17:14:13 2011 -0400
@@ -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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/treeDyn.urp	Thu May 12 17:14:13 2011 -0400
@@ -0,0 +1,4 @@
+database dbname=treeDyn
+sql treeDyn.sql
+
+treeDyn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/treeDyn.urs	Thu May 12 17:14:13 2011 -0400
@@ -0,0 +1,1 @@
+val main : {} -> transaction page