Mercurial > urweb
comparison src/mono_opt.sml @ 1750:277480862cef
'style' attributes
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 06 May 2012 14:01:29 -0400 |
parents | 0577be31a435 |
children | e9587120831a |
comparison
equal
deleted
inserted
replaced
1749:f9e5a8e09cdf | 1750:277480862cef |
---|---|
116 in | 116 in |
117 doChars (String.explode s, []) | 117 doChars (String.explode s, []) |
118 end | 118 end |
119 | 119 |
120 fun checkUrl s = CharVector.all Char.isGraph s andalso Settings.checkUrl s | 120 fun checkUrl s = CharVector.all Char.isGraph s andalso Settings.checkUrl s |
121 val checkAtom = CharVector.all (fn ch => Char.isAlphaNum ch | |
122 orelse ch = #"+" | |
123 orelse ch = #"-" | |
124 orelse ch = #"." | |
125 orelse ch = #"%" | |
126 orelse ch = #"#") | |
127 val checkCssUrl = CharVector.all (fn ch => Char.isAlphaNum ch | |
128 orelse ch = #":" | |
129 orelse ch = #"/" | |
130 orelse ch = #"." | |
131 orelse ch = #"_" | |
132 orelse ch = #"-" | |
133 orelse ch = #"%" | |
134 orelse ch = #"?" | |
135 orelse ch = #"&" | |
136 orelse ch = #"=" | |
137 orelse ch = #"#") | |
138 fun checkProperty s = size s > 0 | |
139 andalso (Char.isLower (String.sub (s, 0)) orelse String.sub (s, 0) = #"_") | |
140 andalso CharVector.all (fn ch => Char.isLower ch orelse Char.isDigit ch orelse ch = #"_" orelse ch = #"-") s | |
121 | 141 |
122 fun exp e = | 142 fun exp e = |
123 case e of | 143 case e of |
124 EPrim (Prim.String s) => | 144 EPrim (Prim.String s) => |
125 let | 145 let |
438 | EFfiApp ("Basis", "checkMime", [((se as EPrim (Prim.String s), loc), _)]) => | 458 | EFfiApp ("Basis", "checkMime", [((se as EPrim (Prim.String s), loc), _)]) => |
439 (if Settings.checkMime s then | 459 (if Settings.checkMime s then |
440 ESome ((TFfi ("Basis", "string"), loc), (se, loc)) | 460 ESome ((TFfi ("Basis", "string"), loc), (se, loc)) |
441 else | 461 else |
442 ENone (TFfi ("Basis", "string"), loc)) | 462 ENone (TFfi ("Basis", "string"), loc)) |
463 | EFfiApp ("Basis", "atom", [((se as EPrim (Prim.String s), loc), _)]) => | |
464 (if checkAtom s then | |
465 () | |
466 else | |
467 ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'atom'"); | |
468 se) | |
469 | EFfiApp ("Basis", "css_url", [((se as EPrim (Prim.String s), loc), _)]) => | |
470 (if checkCssUrl s then | |
471 () | |
472 else | |
473 ErrorMsg.errorAt loc ("Invalid URL " ^ s ^ " passed to 'css_url'"); | |
474 se) | |
475 | EFfiApp ("Basis", "property", [((se as EPrim (Prim.String s), loc), _)]) => | |
476 (if checkProperty s then | |
477 () | |
478 else | |
479 ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'property'"); | |
480 se) | |
443 | EFfiApp ("Basis", "blessRequestHeader", [((se as EPrim (Prim.String s), loc), _)]) => | 481 | EFfiApp ("Basis", "blessRequestHeader", [((se as EPrim (Prim.String s), loc), _)]) => |
444 (if Settings.checkRequestHeader s then | 482 (if Settings.checkRequestHeader s then |
445 () | 483 () |
446 else | 484 else |
447 ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'blessRequestHeader'"); | 485 ErrorMsg.errorAt loc ("Invalid string " ^ s ^ " passed to 'blessRequestHeader'"); |