Mercurial > urweb
changeset 1108:82ac88b4e0a7
Proper client-side attrifyString
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Fri, 01 Jan 2010 10:49:36 -0500 |
parents | 52571ca9b777 |
children | 631a3597c065 |
files | lib/js/urweb.js src/settings.sml tests/sendurl.ur tests/sendurl.urp tests/sendurl.urs |
diffstat | 5 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Thu Dec 31 18:07:53 2009 -0500 +++ b/lib/js/urweb.js Fri Jan 01 10:49:36 2010 -0500 @@ -603,6 +603,10 @@ return decodeURIComponent(s.replace(new RegExp ("\\+", "g"), " ")); } +function atr(s) { + return s.replace(new RegExp ("\"", "g"), """).replace(new RegExp ("&", "g"), "&") +} + function ub(b) { return b ? "1" : "0"; }
--- a/src/settings.sml Thu Dec 31 18:07:53 2009 -0500 +++ b/src/settings.sml Fri Jan 01 10:49:36 2010 -0500 @@ -158,7 +158,7 @@ ("onConnectFail", "onConnectFail"), ("onDisconnect", "onDisconnect"), ("onServerError", "onServerError"), - ("attrifyString", "escape"), + ("attrifyString", "atr"), ("attrifyInt", "ts"), ("attrifyFloat", "ts"), ("attrifyBool", "bs"),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sendurl.ur Fri Jan 01 10:49:36 2010 -0500 @@ -0,0 +1,11 @@ +fun main () = + let + fun getIt () = return (bless "http://www.yahoo.com/") + in + s <- source <xml/>; + return <xml><body> + <dyn signal={signal s}/> + + <button onclick={v <- rpc (getIt ()); set s <xml><a href={v}>Go!</a></xml>}/> + </body></xml> + end