Skip to content

Commit

Permalink
URL/Encoding: change query state parsing
Browse files Browse the repository at this point in the history
See whatwg/encoding#139 for rationale and whatwg/url#386 for the change to the URL Standard.

(I found all these resources in part due to @rakuco's work on trying to align Chrome with the earlier iteration of the specification.)
  • Loading branch information
annevk committed May 9, 2018
1 parent 9b96b14 commit 39db988
Show file tree
Hide file tree
Showing 37 changed files with 46 additions and 90 deletions.
8 changes: 4 additions & 4 deletions encoding/big5-encoder.html
Expand Up @@ -15,17 +15,17 @@

encode("ab", "ab", "very basic")
// edge cases
encode("\u9EA6", "&%2340614;", "Highest-pointer BMP character excluded from encoder");
encode("\uD858\uDE6B", "&%23156267;", "Highest-pointer character excluded from encoder");
encode("\u9EA6", "%26%2340614%3B", "Highest-pointer BMP character excluded from encoder");
encode("\uD858\uDE6B", "%26%23156267%3B", "Highest-pointer character excluded from encoder");
encode("\u3000", "%A1@", "Lowest-pointer character included in encoder");
encode("\u20AC", "%A3%E1", "Euro; the highest-pointer character before a range of 30 unmapped pointers");
encode("\u4E00", "%A4@", "The lowest-pointer character after the range of 30 unmapped pointers");
encode("\uD85D\uDE07", "%C8%A4", "The highest-pointer character before a range of 41 unmapped pointers");
encode("\uFFE2", "%C8%CD", "The lowest-pointer character after the range of 41 unmapped pointers");
encode("\u79D4", "%FE%FE", "The last character in the index");
// not in index
encode("\u2603", "&%239731;", "The canonical BMP test character that is not in the index");
encode("\uD83D\uDCA9", "&%23128169;", "The canonical astral test character that is not in the index");
encode("\u2603", "%26%239731%3B", "The canonical BMP test character that is not in the index");
encode("\uD83D\uDCA9", "%26%23128169%3B", "The canonical astral test character that is not in the index");
// duplicate low bits
encode("\uD840\uDFB5", "%FDj", "A Plane 2 character whose low 16 bits match a BMP character that has a lower pointer");
// prefer last
Expand Down
2 changes: 1 addition & 1 deletion encoding/gbk-encoder.html
Expand Up @@ -17,5 +17,5 @@
encode("\u4E02", "%81@", "character")
encode("\uE4C6", "%A1@", "PUA")
encode("\uE4C5", "%FE%FE", "PUA #2")
encode("\ud83d\udca9", "&%23128169;", "poo")
encode("\ud83d\udca9", "%26%23128169%3B", "poo")
</script>
1 change: 1 addition & 0 deletions encoding/iso-2022-jp-encoder.html
Expand Up @@ -15,4 +15,5 @@
encode("s", "s", "very basic")
encode("\u00A5\u203Es\\\uFF90\u4F69", "%1B(J\\~s%1B(B\\%1B$B%_PP%1B(B", "basics")
encode("\x0E\x0F\x1Bx", "%0E%0F%1Bx", "SO/SI ESC")
encode("\uFFFD", "%26%2365533%3B", "U+FFFD");
</script>
Expand Up @@ -170,10 +170,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -135,10 +135,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -179,10 +179,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -170,10 +170,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -135,10 +135,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -179,10 +179,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -165,10 +165,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -135,10 +135,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -175,10 +175,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -166,10 +166,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -175,10 +175,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -136,10 +136,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -136,10 +136,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -178,10 +178,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -135,10 +135,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -175,10 +175,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -135,10 +135,7 @@
for (var j = 0; j < cplist[i].length; j++) {
var t = tests[i][j];
t.step(function() {
assert_equals(
normalizeStr(results[j]),
normalizeStr(cplist[i][j].expected)
);
assert_equals(results[j], cplist[i][j].expected);
});
t.done();
}
Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -21,7 +21,7 @@
var a = document.createElement("a"); // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input;
result = a.search.substr(1); // remove leading "?"
assert_equals(normalizeStr(result), normalizeStr(expected));
assert_equals(result, expected);
}, desc);
}

Expand Down
Expand Up @@ -14,7 +14,7 @@ onload = function() {
'utf-16be':'%C3%A5',
'utf-16le':'%C3%A5',
'windows-1252':'%E5',
'windows-1251':'&%23229;'
'windows-1251':'%26%23229%3B'
};
var expected_current = expected_obj[encoding];
var expected_utf8 = expected_obj['utf-8'];
Expand Down
7 changes: 7 additions & 0 deletions url/README.md
@@ -1,3 +1,5 @@
## urltestdata.json

These tests are for browsers, but the data for
`a-element.html`, `url-constructor.html`, and `a-element-xhtml.xhtml`
is in `urltestdata.json` and can be re-used by non-browser implementations.
Expand All @@ -19,5 +21,10 @@ The keys for each test case are:
The `origin` key may be missing.
In that case, the API’s `origin` attribute is not tested.

## URL parser's encoding argument

Tests in `/encoding` and `/html/infrastructure/urls/resolving-urls/query-encoding/` cover the
encoding argument to the URL parser.

[parsing]: https://url.spec.whatwg.org/#concept-basic-url-parser
[API]: https://url.spec.whatwg.org/#api

0 comments on commit 39db988

Please sign in to comment.