Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
XMLHttpRequest.responseXML.characterSet may be inaccurate
https://bugs.webkit.org/show_bug.cgi?id=258148

Reviewed by Ryosuke Niwa.

When constructing a document in XMLHttpRequest::responseXML(), we would fail to pass
the TextDecoder we used on the new document (unlike what we do in the HTML parser).
This means that Document::characterSet() would not be able to determine the encoding
our decoder used and would always return UTF-8.

* LayoutTests/imported/w3c/web-platform-tests/html/syntax/charset/xhr-expected.txt:
* Source/WebCore/xml/XMLHttpRequest.cpp:

Canonical link: https://commits.webkit.org/265210@main
  • Loading branch information
cdumez committed Jun 15, 2023
1 parent 1ea5619 commit 64cb5c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
@@ -1,24 +1,24 @@

FAIL Check after-1kb.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check after-1kb.html
PASS Check after-bogus-after-1kb.html
FAIL Check after-bogus.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check after-bogus.html
PASS Check after-head-after-1kb-crlf.html
PASS Check after-head-after-1kb.html
FAIL Check after-head-in-1kb-crlf.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
FAIL Check after-head-in-1kb.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
FAIL Check baseline.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check after-head-in-1kb-crlf.html
PASS Check after-head-in-1kb.html
PASS Check baseline.html
PASS Check document-write.html
PASS Check in-comment.html
PASS Check in-noscript-after-template-after-1kb.html
FAIL Check in-object.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check in-object.html
PASS Check in-script.html
PASS Check in-style.html
FAIL Check in-svg.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check in-svg.html
PASS Check in-svg-in-cdata.html
PASS Check in-template-after-1kb.html
FAIL Check in-template.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check in-template.html
PASS Check in-title.html
FAIL Check ncr.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
FAIL Check non-ascii-in-comment-before.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
FAIL Check non-ascii-in-title-before.html assert_equals: Check characterSet expected "windows-1251" but got "UTF-8"
PASS Check ncr.html
PASS Check non-ascii-in-comment-before.html
PASS Check non-ascii-in-title-before.html

2 changes: 2 additions & 0 deletions Source/WebCore/xml/XMLHttpRequest.cpp
Expand Up @@ -190,6 +190,8 @@ ExceptionOr<Document*> XMLHttpRequest::responseXML()
responseDocument->setSecurityOriginPolicy(context.securityOriginPolicy());
responseDocument->overrideMIMEType(mimeType);
responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
if (m_decoder)
responseDocument->setDecoder(m_decoder.copyRef());

if (!responseDocument->wellFormed())
m_responseDocument = nullptr;
Expand Down

0 comments on commit 64cb5c7

Please sign in to comment.