Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.6.1
-
None
-
769a11719ca85e9cdac4c0f1d0fcffe6145d6972
Description
The implementation of XMLHttpRequest in the QtDeclarative module incorrectly assumes that the document is always formatted as UTF-8. When the data is received from the QNetworkReply it is stored in the 'm_responseEntityBody' QByteArray as raw data. If Javascript code accesses this by calling responseText or responseXml, then the implementation of these functions will call responseBody() which uses fromUtf8() to convert the raw data to a QString.
QXmlStreamReader correctly parses the encoding and attempts to create the appropriate QTextCodec instance, but this only occurs if the QXmlStreamReader is constructed from the raw bytes instead of from a QString (which it assumes is UTF-8 encoded). For the responseXml case, the parsing of the document should happen on the raw bytes instead of on the QString (Document::load should take the QByteArray). For the responseText case, QXmlStreamerReader could be constructed to parse the start document state. At this point, documentEncoding() could be called to get the codec used for coverting the data to a QString.