summaryrefslogtreecommitdiffstats
path: root/caps/tests/unit/test_uri_escaping.js
diff options
context:
space:
mode:
Diffstat (limited to 'caps/tests/unit/test_uri_escaping.js')
-rw-r--r--caps/tests/unit/test_uri_escaping.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/caps/tests/unit/test_uri_escaping.js b/caps/tests/unit/test_uri_escaping.js
new file mode 100644
index 0000000000..7feb581295
--- /dev/null
+++ b/caps/tests/unit/test_uri_escaping.js
@@ -0,0 +1,28 @@
+var ssm = Services.scriptSecurityManager;
+
+function makeURI(uri) {
+ return Services.io.newURI(uri);
+}
+
+function createPrincipal(aURI) {
+ try {
+ var uri = makeURI(aURI);
+ var principal = ssm.createContentPrincipal(uri, {});
+ return principal;
+ } catch (e) {
+ return null;
+ }
+}
+
+function run_test() {
+ Assert.equal(createPrincipal("http://test^test/foo^bar#x^y"), null);
+
+ Assert.equal(createPrincipal("http://test^test/foo\\bar"), null);
+
+ Assert.equal(createPrincipal("http://test:2^3/foo\\bar"), null);
+
+ Assert.equal(
+ createPrincipal("http://test/foo^bar").exposableSpec,
+ "http://test/foo%5Ebar"
+ );
+}