# HG changeset patch # User Adam Chlipala # Date 1231428614 18000 # Node ID d49d58a6987720747d4010fde1a50eb41305a62b # Parent d1ec54288b1ae57d32486683c44bbb03f4250065 Injected a non-special-case datatype diff -r d1ec54288b1a -r d49d58a69877 jslib/urweb.js --- a/jslib/urweb.js Thu Jan 08 10:15:45 2009 -0500 +++ b/jslib/urweb.js Thu Jan 08 10:30:14 2009 -0500 @@ -41,6 +41,10 @@ s.h = cons(function() { x.innerHTML = s.v }, s.h); } +function eh(x) { + return x.split("&").join("&").split("<").join("<").split(">").join(">"); +} + function ts(x) { return x.toString() } function bs(b) { return (b ? "True" : "False") } diff -r d1ec54288b1a -r d49d58a69877 src/jscomp.sml --- a/src/jscomp.sml Thu Jan 08 10:15:45 2009 -0500 +++ b/src/jscomp.sml Thu Jan 08 10:30:14 2009 -0500 @@ -40,7 +40,7 @@ (("Basis", "htmlifyBool"), "bs"), (("Basis", "htmlifyFloat"), "ts"), (("Basis", "htmlifyInt"), "ts"), - (("Basis", "htmlifyString"), "escape"), + (("Basis", "htmlifyString"), "eh"), (("Basis", "new_client_source"), "sc"), (("Basis", "set_client_source"), "sv")] @@ -274,7 +274,10 @@ str loc "}"] else e - | _ => e), + | _ => strcat loc [str loc ("{n:" ^ Int.toString cn + ^ ",v:"), + e, + str loc "}"]), st) end) st cs diff -r d1ec54288b1a -r d49d58a69877 tests/jsinj.ur --- a/tests/jsinj.ur Thu Jan 08 10:15:45 2009 -0500 +++ b/tests/jsinj.ur Thu Jan 08 10:30:14 2009 -0500 @@ -20,6 +20,16 @@ Nil => Nil | Cons (h, t) => {cdata h} :: {delist t} +datatype weird = Foo | Bar | Baz of string + +fun weirdToString w = + case w of + Foo => "Foo" + | Bar => "Bar" + | Baz s => s + +val show_weird = mkShow weirdToString + cookie int : int cookie float : float cookie string : string @@ -28,6 +38,7 @@ cookie option : option int cookie color : color cookie list : list string +cookie weird : weird fun main () : transaction page = n <- getCookie int; @@ -62,6 +73,10 @@ l <- return (getOpt l (Cons ("A", Cons ("B", Nil)))); sl <- source Nil; + w <- getCookie weird; + w <- return (getOpt w (Baz "TADA!")); + sw <- source Foo; + return {[n]}}/> CHANGE
@@ -88,4 +103,7 @@ {delist l}}/> CHANGE
+ + {[w]}}/> + CHANGE