Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7719

XMLHttpRequest ignores document encoding entity

    XMLWordPrintable

Details

    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bealam Bea Lam (closed Nokia identity) (Inactive)
            jabarron Jason Barron
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes