Closed Bug 1109486 Opened 10 years ago Closed 10 years ago

XMLHttpRequest.send(document) should unconditionally encode as UTF-8

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: foolip, Assigned: chenpighead, Mentored)

References

Details

(Keywords: dev-doc-complete, site-compat, testcase, Whiteboard: [lang=c++])

Attachments

(2 files, 2 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2202.3 Safari/537.36 OPR/27.0.1689.2 (Edition developer)

Steps to reproduce:

Compare spec and implementation:
https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
https://github.com/mozilla/gecko-dev/blob/master/dom/base/nsXMLHttpRequest.cpp#L2399


Actual results:

The spec says to unconditionally use UTF-8 while Gecko uses doc->GetDocumentCharacterSet().


Expected results:

Always send as UTF-8. Blink does this, but doesn't include ";charset=UTF-8" in the Content-Type header yet.
Some ad-hoc testing shows that IE appends "; charset=utf-8" which isn't exactly what the spec says, but perhaps close enough.
I just added the ";charset=UTF-8" in Blink:
https://codereview.chromium.org/791783002/

It probably makes sense to make both changes together in Gecko.
I'm told this is tested by web-platform-tests/XMLHttpRequest/send-entity-body-document.htm.
Blocks: xhr2pass
Keywords: testcase
Mentor: bzbarsky
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [lang=c++]
Assignee: nobody → jichen
I avoided using DocumentCharacterSet encoding, and unconditionally set encoding to `UTF-8` as the spec stated.
v1 - mochitest test case patch

I updated the test case to match the spec.
Attachment #8537151 - Flags: review?(bugs)
Attachment #8537666 - Flags: review?(bugs)
Comment on attachment 8537151 [details] [diff] [review]
v1 - Unconditionally use UTF-8 as default Charset

could you fix the comment below
"  // Serialize to a stream so that the encoding used will
  // match the document's."

I guess you could just remove it.


This is a bit risky change, but let's try.
Attachment #8537151 - Flags: review?(bugs) → review+
Attachment #8537666 - Flags: review?(bugs) → review+
(There has been changes like bug 361934 long ago)
Unnecessary code comments have been removed.

please see the try server result here:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=54d05a5c12e1
Attachment #8537151 - Attachment is obsolete: true
Attachment #8537666 - Attachment is obsolete: true
Keywords: checkin-needed
Unnecessary code comments have been removed.

please see the try server result here:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=54d05a5c12e1
Attachment #8538315 - Attachment is obsolete: true
Attachment #8537666 - Attachment is obsolete: false
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/89659f3f1dcf
https://hg.mozilla.org/mozilla-central/rev/dbd205a100a9
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: