http://bugs.webkit.org/show_bug.cgi?id=13905
REGRESSION: A Chinese dictionary widget has a problem with XMLHttpRequest response encoding
Tiger WebKit accidentally looked at HTML Http-Equiv META to determine the response encoding
(regardless of the actual response MIME type). This was corrected a while ago to match other
browsers and the draft XHR spec.
Now restoring this functionality for "text/html", with spec editor's blessing.
* xml/xmlhttprequest.cpp:
(WebCore::XMLHttpRequest::responseMIMEType):
(WebCore::XMLHttpRequest::responseIsXML):
(WebCore::XMLHttpRequest::didReceiveData):
* xml/xmlhttprequest.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23718
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-06-21 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Anders.
+
+ http://bugs.webkit.org/show_bug.cgi?id=13905
+ REGRESSION: A Chinese dictionary widget has a problem with XMLHttpRequest response encoding
+
+ * http/tests/xmlhttprequest/resources/1251.html: Added.
+ * http/tests/xmlhttprequest/response-encoding-expected.txt:
+ * http/tests/xmlhttprequest/response-encoding.html:
+
2007-06-21 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Anders.
--- /dev/null
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=windows-1251">
+</head>
+<body>Ïðîâåðêà</body>
+</html>
Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251 in HTTP headers: Проверка. responseText: <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251 in overrideMimeType: Проверка. responseText: <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
Async: XML transferred as text/plain, UTF-8 as default (ignore XML text declaration): <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
+Async: HTML, charset determined by a META: Проверка
getWithOverride('resources/reply3.xml', 'text/xml; charset=windows-1251', true);
} else if (asyncStep == 8) {
asyncStep = 9;
- log("Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251 in overrideMimeType: " + req.responseXML.getElementsByTagName('node')[0].childNodes[0].nodeValue + ". responseText: " + req.responseText);
+ log("Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251 in overrideMimeType: " +
+ (req.responseXML ? req.responseXML.getElementsByTagName('node')[0].childNodes[0].nodeValue : "<No responseXML>") + ". responseText: " + req.responseText);
get('resources/reply5.txt', true);
} else if (asyncStep == 9) {
+ asyncStep = 10;
log("Async: XML transferred as text/plain, UTF-8 as default (ignore XML text declaration): " + req.responseText);
+ get('resources/1251.html', true);
+ } else if (asyncStep == 10) {
+ log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
}
} else {
log("Error loading URL: status " + req.status);
+2007-06-21 Alexey Proskuryakov <ap@webkit.org>
+
+ Reviewed by Anders.
+
+ http://bugs.webkit.org/show_bug.cgi?id=13905
+ REGRESSION: A Chinese dictionary widget has a problem with XMLHttpRequest response encoding
+
+ Tiger WebKit accidentally looked at HTML Http-Equiv META to determine the response encoding
+ (regardless of the actual response MIME type). This was corrected a while ago to match other
+ browsers and the draft XHR spec.
+
+ Now restoring this functionality for "text/html", with spec editor's blessing.
+
+ * xml/xmlhttprequest.cpp:
+ (WebCore::XMLHttpRequest::responseMIMEType):
+ (WebCore::XMLHttpRequest::responseIsXML):
+ (WebCore::XMLHttpRequest::didReceiveData):
+ * xml/xmlhttprequest.h:
+
2007-06-21 Andrew Wellington <proton@wiretapped.net>
Mac build fix.
return m_response.httpHeaderField(name);
}
-bool XMLHttpRequest::responseIsXML() const
+String XMLHttpRequest::responseMIMEType() const
{
String mimeType = getMIMEType(m_mimeTypeOverride);
if (mimeType.isEmpty())
mimeType = getMIMEType(getResponseHeader("Content-Type"));
if (mimeType.isEmpty())
mimeType = "text/xml";
- return DOMImplementation::isXMLMIMEType(mimeType);
+
+ return mimeType;
+}
+
+bool XMLHttpRequest::responseIsXML() const
+{
+ return DOMImplementation::isXMLMIMEType(responseMIMEType());
}
int XMLHttpRequest::getStatus(ExceptionCode& ec) const
if (!m_decoder) {
if (!m_encoding.isEmpty())
m_decoder = new TextResourceDecoder("text/plain", m_encoding);
+ // allow TextResourceDecoder to look inside the m_response if it's XML or HTML
else if (responseIsXML())
- // allow TextResourceDecoder to look inside the m_response if it's XML
m_decoder = new TextResourceDecoder("application/xml");
+ else if (responseMIMEType() == "text/html")
+ m_decoder = new TextResourceDecoder("text/html");
else
m_decoder = new TextResourceDecoder("text/plain", "UTF-8");
}
void processSyncLoadResults(const Vector<char>& data, const ResourceResponse&);
+ String responseMIMEType() const;
bool responseIsXML() const;
String getRequestHeader(const String& name) const;