Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5, 6.6, 6.7, 6.8, 6.9.0 RC
-
None
-
2
-
4b8659ebf (dev), cfda48772 (6.9), d852646d3 (6.8), 536610798 (tqtc/lts-6.5)
-
Foundation Sprint 128
Description
The patch https://codereview.qt-project.org/c/qt/qtbase/+/419210 converted QXmlStreamReader constructor and addData() method to take QAnyStringView.
However, it didn't set the lockEncoding flag when handling Latin1 strings in addData().
This can lead to an incorrect result when a Latin1-encoded XML document with a proper "encoding" attirbute is passed as a Latin1 string to addData() method:
- at first it will be converted to UTF-8
- later the parser will read the "encoding" attribute, and try to convert the data again into the specified encoding.
A simple test that illustrates the problem:
const auto in = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" "<a>M\xE5rten</a>"_L1; QXmlStreamReader reader; reader.addData(in); QVERIFY(reader.readNextStartElement()); QString text = reader.readElementText(); QCOMPARE(text, "M\xE5rten"_L1); \\ FAIL! The result is "M\u00C3\u00A5rten"
The QXmlStreamReader(QAnyStringView) constructor is not affected, because it already sets the flag correctly.
Attachments
Issue Links
- relates to
-
QTBUG-124636 QXmlStreamReader: don't convert input
-
- Closed
-
-
QTBUG-135129 QXmlStreamReader::addData(QASV) overload unconditionally converts UTF-16 and L1 to UTF-8
-
- Closed
-