summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 4f6a5f22..85d10d4a 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1748,6 +1748,46 @@ function bless(s) {
}
+// CSS validation
+
+function atom(s) {
+ for (var i = 0; i < s.length; ++i) {
+ var c = s[i];
+ if (!isAlnum(c) && c != '+' && c != '-' && c != '.' && c != '%' && c != '#')
+ er("Disallowed character in CSS atom");
+ }
+
+ return s;
+}
+
+function css_url(s) {
+ for (var i = 0; i < s.length; ++i) {
+ var c = s[i];
+ if (!isAlnum(c) && c != ':' && c != '/' && c != '.' && c != '_' && c != '+'
+ && c != '-' && c != '%' && c != '?' && c != '&' && c != '=' && c != '#')
+ er("Disallowed character in CSS URL");
+ }
+
+ return s;
+}
+
+function property(s) {
+ if (s.length <= 0)
+ er("Empty CSS property");
+
+ if (!isLower(s[0]) && s[0] != '_')
+ er("Bad initial character in CSS property");
+
+ for (var i = 0; i < s.length; ++i) {
+ var c = s[i];
+ if (!isLower(c) && !isDigit(c) && c != '_' && c != '-')
+ er("Disallowed character in CSS property");
+ }
+
+ return s;
+}
+
+
// ID generation
var nextId = 0;