Skip to content

Commit

Permalink
Bug 1224643. Fix handling of U+0000 in URLSearchParams serialization.…
Browse files Browse the repository at this point in the history
… r=baku
  • Loading branch information
bzbarsky committed Nov 16, 2015
1 parent f50a8c0 commit f4152a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion dom/base/URLSearchParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ namespace {
void SerializeString(const nsCString& aInput, nsAString& aValue)
{
const unsigned char* p = (const unsigned char*) aInput.get();
const unsigned char* end = p + aInput.Length();

while (p && *p) {
while (p != end) {
// ' ' to '+'
if (*p == 0x20) {
aValue.Append(0x2B);
Expand Down
14 changes: 13 additions & 1 deletion dom/base/test/test_urlSearchParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@
runTest();
}

function testZeroHandling() {
var u = new URLSearchParams;
u.set("a", "b\0c");
u.set("d\0e", "f");
u.set("g\0h", "i\0j");
is(u.toString(), "a=b%00c&d%00e=f&g%00h=i%00j",
"Should encode U+0000 as %00");

runTest();
}

var tests = [
testSimpleURLSearchParams,
testCopyURLSearchParams,
Expand All @@ -301,7 +312,8 @@
testDelete,
testGetNULL,
testSet,
testIterable
testIterable,
testZeroHandling,
];

function runTest() {
Expand Down
5 changes: 0 additions & 5 deletions testing/web-platform/meta/XMLHttpRequest/send-usp.html.ini

This file was deleted.

This file was deleted.

0 comments on commit f4152a3

Please sign in to comment.