summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qxmlstream.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QXmlStreamWriter: fix attempts to write bad QStringsThiago Macieira2024-04-181-2/+6
| | | | | | | | | | | | | We weren't doing the decoding from UTF-16 to UTF-32, so weren't catching invalid code sequences [ChangeLog][QtCore][QXmlStreamWriter] The class now rejects writing UTF-8 and UTF-16 invalid input (improper code unit sequences). Task-number: QTBUG-122241 Pick-to: 6.5 6.6 6.7 Change-Id: I83dda2d36c904517b3c0fffd17b42d17c637fdc4 Reviewed-by: Mate Barany <mate.barany@qt.io>
* QXmlStreamWriter: decode UTF-8 into code pointsThiago Macieira2024-04-181-10/+36
| | | | | | | | | | | | | | | | | | | | | We were iterating over code *units* and that yielded wrong results. The one from the bug report was simply caused by the fact that QUtf8StringView::value_type is char, which is signed on x86, so the expression: *it <= u'\x1F' was true for all non-Latin1 content. But in attempting to fix this, I needed to do the proper UTF-8 decoding, as otherwise we wouldn't catch non-Latin1 sequences and such. [ChangeLog][QtCore][QXmlStreamWriter] Fixed a bug that caused the class to fail to write UTF-8 strings with non-US-ASCII content when passed as a QUtf8StringView. Fixes: QTBUG-122241 Pick-to: 6.5 6.6 6.7 Change-Id: I83dda2d36c904517b3c0fffd17b42bbf09a493d0 Reviewed-by: Mate Barany <mate.barany@qt.io>
* Xml: use new comparison helper macrosTatiana Borisova2024-03-201-16/+23
| | | | | | | | | | | | | | | | | | | | | | New comparison macros are used for following classes: -QXmlStreamAttribute -QXmlStreamNamespaceDeclaration -QXmlStreamNotationDeclaration -QXmlStreamEntityDeclaration Replace public operators operator==(), operator!=() of classes to friend methods comparesEqual(); Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Add checkStreamNotationDeclarations()/checkStreamEntityDeclarations() test-cases to test change. Task-number: QTBUG-120300 Change-Id: I0b5642b2e23cc21ede7bc4888f0a9bddd6c08d07 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix renamed and duplicated namespaces in QXmlStreamWriterØystein Heskestad2023-09-201-14/+54
| | | | | | | | | | | | | | | The XML stream writer previously added namespace declarations with the same URL as existing ones, but new names, and renamed the XML elements to use the new namespaces instead of the existing ones. [ChangeLog] Fix renamed and duplicated namespaces in QXmlStreamWriter. Pick-to: 6.5 6.6 Fixes: QTBUG-75456 Change-Id: I90706e067ac9991e9e6cd79ccb2373e4c6210b7b Done-With: Philip Allgaier <philip.allgaier@bpcompass.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QXmlStreamReader::readNextStartElement() - return false on document endAxel Spoerl2023-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The method reads the next element in a loop, as long as valid elements exist. Within the loop, it returns - false if the end of an element has been reached - true if a new element has started When the document end has been reached, the loop continues, until readNext() returns Invalid. Then, PrematureEndOfDocumentError is launched. This is wrong, because reading beyond the document end is caused by a missing return condition in the loop. => Treat document end like element end and return false without reading beyond it. => Test correct behavior in tst_QXmlStream::readNextStartElement() Fixes: QTBUG-25944 Pick-to: 6.6 6.5 6.2 Change-Id: I0160b65880756a2be541e9f55dc79557fcb1f09f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXmlStreamReader: Fix translation context of error messagesFriedemann Kleint2023-07-241-2/+2
| | | | | | | | | | | | QObject::tr() should not be used. Amends c4301be7d5f94852e1b17f2c2989d5ca807855d4. Task-number: QTBUG-92113 Task-number: QTBUG-95188 Pick-to: 6.6 6.5 Change-Id: I09547c3d048d6b3726e33be74b06035f0eec4f31 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QXmlStreamReader: Fix variable namingAxel Spoerl2023-07-111-4/+4
| | | | | | | | | | | Replace variable names referring to XML "location" with names referring to XML context. Task-number: QTBUG-92113 Task-number: QTBUG-95188 Pick-to: 6.6 6.5 Change-Id: If00e92dce237d95fa1850f0b45192995724ba99f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QXmlStreamReader: Raise error on unexpected tokensAxel Spoerl2023-07-101-8/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QXmlStreamReader accepted multiple DOCTYPE elements, containing DTD fragments in the XML prolog, and in the XML body. Well-formed but invalid XML files - with multiple DTD fragments in prolog and body, combined with recursive entity expansions - have caused infinite loops in QXmlStreamReader. This patch implements a token check in QXmlStreamReader. A stream is allowed to start with an XML prolog. StartDocument and DOCTYPE elements are only allowed in this prolog, which may also contain ProcessingInstruction and Comment elements. As soon as anything else is seen, the prolog ends. After that, the prolog-specific elements are treated as unexpected. Furthermore, the prolog can contain at most one DOCTYPE element. Update the documentation to reflect the new behavior. Add an autotest that checks the new error cases are correctly detected, and no error is raised for legitimate input. The original OSS-Fuzz files (see bug reports) are not included in this patch for file size reasons. They have been tested manually. Each of them has more than one DOCTYPE element, causing infinite loops in recursive entity expansions. The newly implemented functionality detects those invalid DTD fragments. By raising an error, it aborts stream reading before an infinite loop occurs. Thanks to OSS-Fuzz for finding this. Fixes: QTBUG-92113 Fixes: QTBUG-95188 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I0a082b9188b2eee50b396c4d5b1c9e1fd237bbdd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QXmlStreamReader: use std::optionalAhmad Samir2023-07-061-7/+6
| | | | | | | | | | | | The optional-like FastScanNameResult was used to make some previous changes backport-able to Qt 5.15 (std::optional is C++17 whereas Qt 5.15 requires C++14). Amends commit 6326bec46a618c72feba4a2bb994c4d475050aed. Pick-to: 6.6 6.5 Change-Id: I409e1da83f82927c1eb24c47c1414c0c7ab1bf5b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix typo in QXmlStreamReader error messageFriedemann Kleint2023-06-301-1/+1
| | | | | | | | | | Amends 6326bec46a618c72feba4a2bb994c4d475050aed. Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-109781 Task-number: QTBUG-114829 Change-Id: Ib5189dc908cd61c6c6fa23024776a4a5baa75ca5 Reviewed-by: Robert Löhning <robert.loehning@qt.io>
* QXmlStreamReader: make fastScanName() indicate parsing status to callersAhmad Samir2023-06-281-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a crash while parsing an XML file with garbage data, the file starts with '<' then garbage data: - The loop in the parse() keeps iterating until it hits "case 262:", which calls fastScanName() - fastScanName() iterates over the text buffer scanning for the attribute name (e.g. "xml:lang"), until it finds ':' - Consider a Value val, fastScanName() is called on it, it would set val.prefix to a number > val.len, then it would hit the 4096 condition and return (returned 0, now it returns the equivalent of std::null_opt), which means that val.len doesn't get modified, making it smaller than val.prefix - The code would try constructing an XmlStringRef with negative length, which would hit an assert in one of QStringView's constructors Add an assert to the XmlStringRef constructor. Add unittest based on the file from the bug report. Later on I will replace FastScanNameResult with std::optional<qsizetype> (std::optional is C++17, which isn't required by Qt 5.15, and we want to backport this fix). Credit to OSS-Fuzz. Fixes: QTBUG-109781 Fixes: QTBUG-114829 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I455a5eeb47870c2ac9ffd0cbcdcd99c1ae2dd374 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QXmlStreamReader: change fastScanName() to take a Value*Ahmad Samir2023-06-281-8/+8
| | | | | | | | For easier debugging, e.g. to print out value.len and value.prefix. Pick-to: 6.6 6.5 6.5.2 6.2 5.15 Change-Id: Ib0eed38772f899502962f578775d34ea2744fdde Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QXmlStreamReader: Add key/value to "Invalid attribute" error messageAxel Spoerl2023-06-041-1/+1
| | | | | | | | | | | | | | When QXmlReaderPrivate::startDocument() parses declarations, it reports an error if a declaration contains an unknown attribute. The message doesn't mention the invalid attribute's key and value, so the user has to guess which one is the faulty declaration. This patch extends the error message by adding the respective key/value pair. Pick-to: 6.5 Change-Id: I7f5a228bed44937472880c3b3d63d5e816b39361 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Convert remaining QT_NO_XMLSTREAM* to use feature systemEdward Welbourne2023-05-151-13/+14
| | | | | | | | | | | | | | | | Replace the check in qxmlstream.h with a QT_REQUIRE_CONFIG since the code that includes this header does no checking, whether on the define or the feature, so is better off getting told about the missing feature at the point of include than complaining about an undefined type despite its header being overtly included. For the rest, just do the usual transformation to QT_CONFIG(), flipping the ones that were #ifdef rather than #ifndef, so the condition is positive. Shifted a couple of open-braces of classes to the next line, where they belong, in the process. Change-Id: If9c496082f0489b0f9f4070364cbf840e603fce1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Fix documentation warningsTopi Reinio2023-04-291-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These warnings slipped in during a time period where documentation testing in the CI was disabled. src/network/kernel/qhostinfo.cpp:254: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> int QHostInfo::lookupHost(const QString &name, Functor functor) src/widgets/widgets/qcheckbox.cpp:102: (qdoc) warning: clang couldn't find function when parsing \fn void QCheckBox::stateChanged(Qt::CheckState state) src/corelib/kernel/qcoreapplication.cpp:2769: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> void QCoreApplication::requestPermission( const QPermission &permission, Functor functor) src/corelib/serialization/qxmlstream.cpp:3806: (qdoc) warning: clang couldn't find function when parsing \fn bool QXmlStreamAttributes::hasAttribute( const QString &qualifiedName) const src/corelib/text/qtliterals.qdoc:11: (qdoc) warning: Multiple topic commands found in comment: \namespace and \headerfile. Pick-to: 6.5 Change-Id: I38c605f358dbca1ef3e2bfe20a6424f7a4d44b4a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Implement QXmlStreamReader::hasStandaloneDeclaration()Axel Spoerl2023-04-261-0/+17
| | | | | | | | | | | | | | | This patch implements a public getter for the hasStandalone attribute. It returns true, if standalone has been explicitly declared in an XML header and false otherwise. As this is no longer necessary it removes accessing QXmlStreamPrivate from QDomParser. [ChangeLog][QtCore][QXmlStreamReader] added hasStandaloneDeclaration() Change-Id: Iaaa0a728a6f7186e40637186077f7b49c112f7a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Yuhang Zhao <yuhangzhao@deepin.org>
* QXmlStreamAttributes: port value()/hasAttribute() to QAnyStringViewMarc Mutz2023-04-251-49/+6
| | | | | | | | | | [ChangeLog][QtCore][QXmlStreamAttributes] Ported value() and hasAttribute() to QAnyStringView. Change-Id: I771b9cede1d581d3f1142246e7a25c36bcc850d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QDomDocument: no longer drop a provided 'standalone' attribute if 'no'Axel Spoerl2023-04-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Definition of 'standalone' attribute: An XML declaration containing the attribute 'standalone' with its value set to 'yes', tells the parser to ignore markup declarations in the DTD and to use them only for validation. The declaration attribute is optional and defaults to 'no'. - Behavior Qt5 In qt5, DOM documents contained the standalone attribute, regardless of whether or not it was explicitly specified. - Behavior Qt6 In Qt6, the standalone attribute was only contained in a DOM document, if its value was 'yes'. If it was explicitly declared with the value being 'no', it was dropped in the DOM document. - Expected behavior If the source specified it overtly, then the generated XML should contain the attribute, even when it takes its default value. - Code base QXmlStreamReader provides a public bool getter isStandaloneDocument(). This says whether the document is standalone or not. The information whether the attribute was actually specified gets lost. In consequence, the attribute was always dropped on non-standalone documents. - Fix This patch makes hasStandalone a member of QXmlStreamReaderPrivate, to record whether the attribute has been explicitly specified. QDomParser is modified to retain the standalone attribute, if QXmlStreamReaderPrivate::hasStandalone is true. - Test The patch adds a test function in tst_QDom. Fixes: QTBUG-111200 Pick-to: 6.5 6.2 Change-Id: I06a0f230a2d69597dd6453f8fd3b036943d08735 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Replace ushort*/uint* with char16_t*/char32_t* in private API [1]Ahmad Samir2023-03-151-1/+1
| | | | | | | Task-number: QTBUG-110403 Pick-to: 6.5 Change-Id: Ie20a831f22212d56659cf3c6940d17134ab5f2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXmlStreamWriter: hold the indent in std::string, not QByteArrayMarc Mutz2023-02-281-3/+4
| | | | | | | | | | | This means that, thanks to std::string's SSO, we won't allocate to hold the indent step string anymore, at least for non-pathological indents of up to 15-23 characters, depending on the particular std::string implementation. Task-number: QTBUG-103302 Change-Id: I63685619e86a3aa7bcfac41db84f64a78859bdb7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Remove duplicate wordsAndreas Eliasson2023-02-281-1/+1
| | | | | | Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7 Pick-to: 6.5 6.4 6.2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtMiscUtils: add some more character helpersAhmad Samir2023-02-071-3/+3
| | | | | | | | | | | | | isHexDigit, isOctalDigit, isAsciiDigit, isAsciiLower, isAsciiUpper, isAsciiLetterOrNumber. This de-duplicates some code through out. Rename two local lambdas that were called "isAsciiLetterOrNumber" to not conflict with the method in QtMiscUtils. Change-Id: I5b631f95b9f109136d19515f7e20b8e2fbca3d43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Disambiguate static variablesFriedemann Kleint2023-02-021-1/+1
| | | | | | | | | They cause clashes in CMake Unity (Jumbo) builds. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I5f1fbee07872a742a78adc9864fe00c710ca24d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize QXmlStreamWriterPrivate::doWriteToDevice(QLatin1StringView)Marc Mutz2023-01-191-4/+8
| | | | | | | | | | | | Use a stack buffer, and perform the recoding from L1 to U8 in chunks. Solves the L1 case of Task-number: QTBUG-109284 Pick-to: 6.5 Change-Id: Ia9ac7d8b27fd452d24d9e27f0575f9fc83b6dcbc Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamReader: fix spelling of PrivateConsructorTagMarc Mutz2023-01-181-1/+1
| | | | | | | | Found in API review. Pick-to: 6.5 Change-Id: I347ae3cc6a51095dddaba617adc2f63612578ef3 Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
* QXmlStreamWriter: fix a thinko in doWriteToDevice(QSV)Marc Mutz2022-12-161-4/+2
| | | | | | | | | | | | | | Check for state.remainingChars to signal an encoding error only after the last chunk has been processed. Splitting surrogates at chunk boundaries is normal operation, not an error. Only if this happens at the end of the whole input should we raise an error. Amends fa2153bd10057d7adbc5f5ededa1fd97c4a68161. Pick-to: 6.5 Change-Id: Id92e37becaed25bbc11e0c22dedc4d41fb23f92a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize QXmlStreamWriterPrivate::doWriteToDevice(QStringView)Marc Mutz2022-12-111-6/+12
| | | | | | | | | | | | | Use a stack buffer, and perform the recoding from U16 to U8 in chunks. Since no-one so far managed to get a chunked QStringEncoder to produce the same output as the test expected, at least not without additional API, fall back to the raw QUtf8 functions. This also avoids the indirect function call overhead that QStringEncoder would entail. Fixes: QTBUG-109284 Change-Id: Icaa26c3988ac8506c9cf3fde18fd5892e5e63ef2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamWriter: remove unneeded QStringView::toString() callsMarc Mutz2022-12-111-15/+12
| | | | | | | | | | | Now that QXmlStreamWriter's APIs take QAnyStringView, there's no need to convert the QStringViews we get from e.g. QXmlStreamReader APIs to QString first. Task-number: QTBUG-103302 Change-Id: Iab33dbfb5da7b3501cae0d0ab7f7ecdb61cca784 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamWriter: remove unused [[maybe_unused]]Marc Mutz2022-12-111-3/+0
| | | | | | | | | | Q_ASSERT() already ensures its argument gets compiled even with QT_NO_DEBUG, but then skipped as dead code. Task-number: QTBUG-103302 Change-Id: I6614b23967e2bb506e52f1493526564a0b5955be Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamWriter: remove Private::write(data, ptr)Marc Mutz2022-12-111-8/+2
| | | | | | | | | | ... and port the last remaining user over to the QAnyStringView overload. Task-number: QTBUG-103302 Change-Id: I7edd855d6c2bc16180c642191aa0d477586c1e0b Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamWriter: port API from QString to QAnyStringViewMate Barany2022-12-101-19/+67
| | | | | | | | | | | | | | | QXmlStreamWriter is basically a fancy way to append to a string, not saving any of them individually, so this API is a perfect candidate for replacing all of the QStrings with QAnyStringViews. [ChangeLog][QtCore][QXmlStreamWriter] Ported API to QAnyStringView (was: QString). Fixes: QTBUG-103302 Change-Id: I9fb1f2d5793cf9f35d468c46c0127d3ebd57f3dd Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QXmlStreamWriter: prepare for port to QAnyStringViewMarc Mutz2022-12-101-12/+80
| | | | | | | | | | | | | | | | | | | | | The UTF-8 support in Qt is still lacking, so QUtf8StringView doesn't, yet, have the likes of contains(), endsWith(), etc that the existing QString code uses in Q_ASSERTs. Provide free functions that work for UTF-8 haystacks and ASCII needles by falling back to QByteArrayView or QLatin1StringView. Also break a replace() use into a series of indexOf() + chunked write(). This is rather expensive for QString, so port the writeCDATA() function that uses this to QAnyStringView already, ahead of the bulk of the changes in Mate's follow-up patch. Task-number: QTBUG-103302 Change-Id: Ic66261740817ede2600b78a383cf667a31df7bfc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* Port QXmlStreamWriterPrivate::writeEscaped to QAnyStringViewMate Barany2022-12-101-45/+56
| | | | | | | | | This is a prerequisite step of porting QXmlStreamWriter to QAnyStringView. Task-number: QTBUG-103302 Change-Id: Icdbe3d23bd96461b0ace497ac9995040cfcdb470 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Port QXmlStreamWriterPrivate::writeStartElement to QAnyStringViewMate Barany2022-12-101-2/+2
| | | | | | | | | This is a prerequisite step of porting the QXmlStreamWriter API to QAnyStringView. Task-number: QTBUG-103302 Change-Id: I73383c2b09a4a70bfc23bbc6c6b1d62cb878a6b1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Port QXmlStreamWriterPrivate::findNameSpace to QAnyStringViewMate Barany2022-12-101-2/+2
| | | | | | | | | This is a prerequisite of porting the QXmlStreamWriter API to QAnyStringView. Task-number: QTBUG-103302 Change-Id: I1433de66c9aefe6f3e8f7cd8e831718d2db88eb6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Port QXmlStreamWriterPrivate::write to QAnyStringViewMate Barany2022-12-101-46/+39
| | | | | | | | | | | | | | | Replace the const QString &s overload with a QASV overload. Remove the const char (&s)[N] and const XmlStringRef& overloads, with the QASV overload they are redundant. Leave the const char *s, qsizetype len overload for now but make it call the QASV overload. Task-number: QTBUG-103302 Change-Id: I4f92d76248d5b7531472056a51ca06aa25dbac01 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Document Qt Serialization with use casesJaishree Vyas2022-12-081-0/+3
| | | | | | | | | | | Added some background about Serialization with the classes and used cases. Fixes: QTBUG-103951 Pick-to: 6.4 6.3 6.2 Change-Id: I3ff179b814fc5d424f2ac2ffaf3237b90ddd7e2b Reviewed-by: Vladimir Minenko <vladimir.minenko@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QXmlStreamReader: use qOffsetStringArray for storing token typesSona Kurazyan2022-09-061-51/+16
| | | | | Change-Id: I9e58c17d97c44e1b13899d30396f65b452d8600f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Format certain operators in textPaul Wicking2022-08-231-2/+2
| | | | | | | | | | Use correct text formatting; this ensures e.g. the decrement operator isn't converted to an en dash in the docs. Apply to increment operator docs also for consistency. Task-number: QTBUG-105729 Change-Id: I5f126b90bc1d1b91d86e1f87c9b17a583841adb6 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QXmlStreamReader: fix C++20 buildGiuseppe D'Angelo2022-07-151-1/+1
| | | | | | | Amends 6bc227a06a0d1392d220aa79ddb1cdc145d4f76e. Change-Id: I47384ce60093cb85a651c16667738dac69e0e747 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Port QXmlStremReader to QAnyStringViewSona Kurazyan2022-07-121-50/+78
| | | | | | | | | | | | | | | | Port the constructor and addData() method to QAnyStringView, but keep the overloads taking a QByteArray to avoid extra copies when actual QByteArray is passed. These overlaods need to be Q_WEAK_OVERLOADs, to avoid ambiguities (e.g. for const char * arguments). Additionally, add a test to make sure the patch doesn't break parsing from a QLatin1StringView input. [ChangeLog][QtCore][QXmlStremReader] Added constructor and addData() overloads taking QAnyStringView. Change-Id: I0efaab82a2123271c88407e380f3c67d1099a4a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QXmlStreamReader: port Value::len from int to qsizetypeMarc Mutz2022-05-071-11/+11
| | | | | | | | | | | | It's a stretch of characters in a QString, so it has to be qsizetype. This enlarges the Value struct further; created QTBUG-103306 to track ideas to shrink it again. Pick-to: 6.3 6.2 Fixes: QTBUG-102465 Change-Id: I753cfd801030c834989452eb5422b2cd72d4ef16 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStreamReader: port Value::prefix from int to qint16Marc Mutz2022-05-071-3/+3
| | | | | | | | | | | | | | | | | The prefix is a part of a name, the length of which is bounded to 4k in fastScanName(), so qint16 suffices. The length field also shouldn't stay int, but that's a different patch, because it's just a relative offset to pos, and so isn't as easily overflown. This shrinks the Value struct a tiny bit; created QTBUG-103306 to track ideas to shrink it further. Pick-to: 6.3 6.2 Task-number: QTBUG-102465 Change-Id: I579815e72501a091360f55e750af63cb4dc5a5a7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QXmlStreamWriter: port Private::write(p, n) from int to qsizetypeMarc Mutz2022-05-071-2/+2
| | | | | | | | | | | We have at least one caller which passes QtContainer::size() as the length, so don't truncate. Pick-to: 6.3 6.2 Task-number: QTBUG-102465 Change-Id: I8a692bd6a7b75e745c08b072f53b6efe901d5436 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QXmlStreamReader: port some int → qsizetypeMarc Mutz2022-05-071-11/+10
| | | | | | | | | | Port function-local variables where local static reasoning dictates they should have been qsizetype, not int. Pick-to: 6.3 6.2 Task-number: QTBUG-102465 Change-Id: I0d7b07699b6dd379bce4b44f172815fb6335b1a1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXmlStreamReader: fix integer truncation (qint64 → int)Marc Mutz2022-05-071-1/+1
| | | | | | | | | | | | We don't care about the actual type of oldLineNumber here, we just need it to be of the same type as lineNumber, to avoid truncation, so we use auto. This was already broken in 5.15 (lineNumber was already a qint64). Pick-to: 6.3 6.2 5.15 Change-Id: I68d7e6e91c8122bf426c9c10e8cc91ff55c61a20 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXmlStreamWriter: replace indexed with ranged for loopsMarc Mutz2022-05-071-5/+3
| | | | | | | | | Simpler, and fixes the int/qsizetype mismatches. Pick-to: 6.3 6.2 Task-number: QTBUG-102465 Change-Id: I8ac139a14c4c790348acd76b95d1bee83bb2797d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-12/+18
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>