aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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