summaryrefslogtreecommitdiff
path: root/src/mono_opt.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-05-06 14:01:29 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-05-06 14:01:29 -0400
commit9e25c1ce13add31807463c913129c24643944e38 (patch)
treeccabcef63f0d66632cc4c8c486c6d3663eef3ced /src/mono_opt.sml
parent4387731e477e2af050841f916a03f5d8a975a164 (diff)
'style' attributes
Diffstat (limited to 'src/mono_opt.sml')
-rw-r--r--src/mono_opt.sml38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mono_opt.sml b/src/mono_opt.sml
index 199c807b..af9e9a9c 100644
--- a/src/mono_opt.sml
+++ b/src/mono_opt.sml
@@ -118,6 +118,26 @@ fun unAs s =
end
fun checkUrl s = CharVector.all Char.isGraph s andalso Settings.checkUrl s
+val checkAtom = CharVector.all (fn ch => Char.isAlphaNum ch
+ orelse ch = #"+"
+ orelse ch = #"-"
+ orelse ch = #"."
+ orelse ch = #"%"
+ orelse ch = #"#")
+val checkCssUrl = CharVector.all (fn ch => Char.isAlphaNum ch
+ orelse ch = #":"
+ orelse ch = #"/"
+ orelse ch = #"."
+ orelse ch = #"_"
+ orelse ch = #"-"
+ orelse ch = #"%"
+ orelse ch = #"?"
+ orelse ch = #"&"
+ orelse ch = #"="
+ orelse ch = #"#")
+fun checkProperty s = size s > 0
+ andalso (Char.isLower (String.sub (s, 0)) orelse String.sub (s, 0) = #"_")
+ andalso CharVector.all (fn ch => Char.isLower ch orelse Char.isDigit ch orelse ch = #"_" orelse ch = #"-") s
fun exp e =
case e of
@@ -440,6 +460,24 @@ fun exp e =
ESome ((TFfi ("Basis", "string"), loc), (se, loc))
else
ENone (TFfi ("Basis", "string"), loc))
+ | EFfiApp ("Basis", "atom", [((se as EPrim (Prim.String s), loc), _)]) =>
+ (if checkAtom s then
+ ()
+ else
+ ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'atom'");
+ se)
+ | EFfiApp ("Basis", "css_url", [((se as EPrim (Prim.String s), loc), _)]) =>
+ (if checkCssUrl s then
+ ()
+ else
+ ErrorMsg.errorAt loc ("Invalid URL " ^ s ^ " passed to 'css_url'");
+ se)
+ | EFfiApp ("Basis", "property", [((se as EPrim (Prim.String s), loc), _)]) =>
+ (if checkProperty s then
+ ()
+ else
+ ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'property'");
+ se)
| EFfiApp ("Basis", "blessRequestHeader", [((se as EPrim (Prim.String s), loc), _)]) =>
(if Settings.checkRequestHeader s then
()