1description("Tests mailto: URL canonicalization"); 2 3cases = [ 4 ["addr1", "addr1"], 5 ["addr1@foo.com", "addr1@foo.com"], 6 7 // Trailing whitespace is stripped. 8 ["addr1 \t ", "addr1"], 9 ["addr1?to=jon", "addr1?to=jon"], 10 ["addr1,addr2", "addr1,addr2"], 11 ["addr1, addr2", "addr1, addr2"], 12 ["addr1%2caddr2", "addr1%2caddr2"], 13 14 // U+10300 input as UTF-16 surrogate pair, expected as escaped UTF-8 15 ["\uD800\uDF00", "%F0%90%8C%80"], 16 ["addr1?", "addr1?"], 17 18 // Null character should be escaped to %00 19 // Not sure how to test null characters in JavaScript. They appear to get 20 // stripped out. 21 // ["addr1\\0addr2?foo", "addr1%00addr2?foo"], 22]; 23 24for (var i = 0; i < cases.length; ++i) { 25 shouldBe("canonicalize('mailto:" + cases[i][0] + "')", 26 "'mailto:" + cases[i][1] + "'"); 27} 28 // Invalid -- UTF-8 encoded surrogate value. 29shouldBeFalse("canonicalize('mailto:\xed\xa0\x80') == 'mailto:%EF%BF%BD'"); 30 31var successfullyParsed = true; 32