summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-11-26 11:57:04 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-11-26 11:57:04 -0500
commit0de429f2205e351ac4ca182aca072e25e09ed33a (patch)
tree797cfeacd60b528213c49c09abf7da63ba136ad8 /lib/js/urweb.js
parent884fd425458185205bc2b6109a58028d0d881b53 (diff)
Fix JavaScript unit unurlification; URL blessing client-side
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 8ca6b89c..f98476b7 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1182,5 +1182,26 @@ function confrm(s) {
}
+// URL blessing
+
+var urlRules = null;
+
+function checkUrl(s) {
+ for (var r = urlRules; r; r = r.next) {
+ var ru = r.data;
+ if (ru.prefix ? s.indexOf(ru.pattern) == 0 : s == ru.pattern)
+ return ru.allow ? s : null;
+ }
+
+ return null;
+}
+
+function bless(s) {
+ u = checkUrl(s);
+ if (u == null)
+ er("Disallowed URL: " + s);
+ return u;
+}
+
// App-specific code