summaryrefslogtreecommitdiffstats
path: root/caps/tests/unit/test_uri_escaping.js
blob: 7feb58129557e0cc72a6cce3897b2fb1e3408852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"
  );
}