Bug 1224643. Fix handling of U+0000 in URLSearchParams serialization. r=baku

This commit is contained in:
Boris Zbarsky 2015-11-16 13:29:55 -05:00
parent 6c7ae69493
commit 1e471fc1dd
4 changed files with 15 additions and 12 deletions

View File

@ -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);

View File

@ -289,6 +289,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
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,
@ -301,7 +312,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
testDelete,
testGetNULL,
testSet,
testIterable
testIterable,
testZeroHandling,
];
function runTest() {

View File

@ -1,5 +0,0 @@
[send-usp.html]
type: testharness
[XMLHttpRequest.send(URLSearchParams) (0)]
expected: FAIL

View File

@ -1,5 +0,0 @@
[send-usp.worker]
type: testharness
[XMLHttpRequest.send(URLSearchParams) (0)]
expected: FAIL