If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

XMLHttpRequest request truncated at null character ('\0')

RESOLVED WORKSFORME

Status

()

Core
XML
RESOLVED WORKSFORME
11 years ago
a year ago

People

(Reporter: David Batley, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-UK; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-2) It was me, I was the turkey all along
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-UK; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-2)




//create a string containing a NULL character
var text = "WELCOME" + String.fromCharCode(0) + "HELLO WORLD!!";
alert("Text length is " + String(text.length));

//send text as POST to example.com
var hx = new XMLHttpRequest;
hx.open('POST', "http://example.com", true);
hx.onreadystatechange = function () { ; }
hx.setRequestHeader("Content-Type", "application/x-example");
hx.send(text);

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
(Reporter)

Comment 1

11 years ago
Code above only sends "WELCOME" part and stops at NULL character. If string starts with zero char then no data part is sent.
Summary: XMLHttpRequest incorrectly handles characcer 0 → XMLHttpRequest incorrectly handles character 0 for HTTP POST

Updated

11 years ago
Assignee: nobody → xml
Component: General → XML
Product: Firefox → Core
QA Contact: general → ashshbhatt
Summary: XMLHttpRequest incorrectly handles character 0 for HTTP POST → XMLHttpRequest request truncated at null character ('\0')
definitely a bug on the 1.8 branch:
http://lxr.mozilla.org/mozilla1.8/source/content/base/src/nsXMLHttpRequest.cpp#1548

not sure about trunk...
Assignee: xml → nobody
QA Contact: ashshbhatt → xml

Comment 3

a year ago
It seems this bug can be closed. On today's nightly, the example above now sends the full text to the server (confirmed with a trivial PHP script that simply outputs the POST body it received).
Flags: needinfo?(bugs)
Feel free to resolve as worksforme. If there are still issues, one can always reopen the bug or file a new one.
Flags: needinfo?(bugs)

Updated

a year ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.