summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qxmlstream.cpp
Commit message (Collapse)AuthorAgeFilesLines
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Don't parse XML symbols longer than 4096 charactersAllan Sandfeld Jensen2021-04-161-0/+5
| | | | | | | | | It is slow and will use too much memory. Pick-to: 6.1 6.1.0 6.0 5.15 Fixes: QTBUG-91889 Change-Id: I45c5e6038357c87bbb85b1ace17ef39a2a814ea0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace qt_make_unique with std::make_uniqueAllan Sandfeld Jensen2020-11-231-2/+1
| | | | | | | We can depend on C++14 now. Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStream: sanitize input before building a QCharGiuseppe D'Angelo2020-11-181-2/+2
| | | | | | | | | | The result of getChar() may be a combination of a token category and a code unit, like `((LETTER << 16) | c)`. Constructing a QChar out of it requires masking the category out. This was already done in a few code paths but missing in others. Change-Id: I186fb01973a1badd425b3a6811843d8a40b13a6a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-2/+2
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Doc: Add missing brief statements for \property documentationTopi Reinio2020-11-121-2/+2
| | | | | | | | ... where applicable. Fixes: QTBUG-88232 Change-Id: I835df434765caededd35d5114965b4a1663e7942 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Convert a couple of APIs to use viewsLars Knoll2020-10-061-3/+3
| | | | | | | | | | | Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix qdoc warning from documentation of internal APIVolker Hilsheimer2020-09-301-7/+0
| | | | | | | | | QXmlString is an internal class, so qdoc cannot tie the member function documentation to anything. Since "swap" is rather self-explanatory anyway, we can just remove the (somewhat oddly placed) documentation. Change-Id: I3d47219a628ba3d3e5ecd0c825eeff71908d07e9 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove traces of QObject::trUtf8 from documentationVolker Hilsheimer2020-09-251-4/+0
| | | | | | | | ... and from the duplicated Q_DECLARE_TR_FUNCTION macro for QXmlStream. We expect source code to be utf8 encoded in Qt 6, so the function is gone. Change-Id: Ie25329a54e709dc92a22893ad5ab023852300d81 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Port QXmlStreamReader from QStringRef to QStringViewKarsten Heimrich2020-08-191-31/+31
| | | | | | | | | | | Use the new QtPrivate::XmlString class as the container holding the string data internally. It basically a "QStringRef lite", purely used in the implemntation. This replaces all usages of QStringRef in the parser. Fixes: QTBUG-84318 Change-Id: I557bbc6831301866602586d11d53283affd034a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QXmlStreamSimpleStack to work also with non POD data typesLars Knoll2020-08-191-3/+3
| | | | | | | | | | The current code is already undefined behavior, as QStringRef is not POD. It happened to work, because the destructor is empty. Fix this and rather let the compiler determine whether it needs to call any constructors or destructors. Change-Id: Idc8710df539603b0ca401a9453f2501f01beaab4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor QXmlStreamStringRefKarsten Heimrich2020-08-191-31/+31
| | | | | | | | | | | | | Use a QStringPrivate inside the implementation. This saves two pointers, and actually makes this a safe replacement for QStringRef inside the implementation of QXmlStreamReader. Unexport the class as all members are inline, and move it into the QtPrivate namespace as class QXmlString. Change-Id: I43fa4684f569514c8c621838dcc346657ac1a915 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Smaller change towards using QStringViewLars Knoll2020-08-191-2/+2
| | | | | | Change-Id: I6e74a83303e2d9dd278b47aaf488e717eca3fc6d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor qxmlstream_p.hLars Knoll2020-08-191-2/+2
| | | | | | | | | | Pull the file apart, so that the parts generated from qxmlstream.g are separated from the definition of the private class. This will in the future simplify maintenance and refactoring. Change-Id: I4a9c1bb1e377dee1e6d3b9aa9b0dfa64c5806c45 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Port the QXmlStream API from QStringRef to QStringViewKarsten Heimrich2020-08-191-49/+45
| | | | | | | | | | | | | | This gives some source incompatibilities, most of them can be handled by using auto instead of QStringRef explicitly. [ChangeLog][Important API changes] QXmlStream now uses QStringView insteead of QStringRef in it's API. Using auto forvariables returning a QStringRef in Qt 5 should lead to code that can be used against both Qt versions. Fixes: QTBUG-84317 Change-Id: I6df3a9507276f5d16d044a6bdbe0e4810cf99440 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* QXmlStreamReader: Don't resize readBuffer to a size it already hasRobert Loehning2020-08-121-1/+2
| | | | | | | | | | | Resizing it to 0 will cause it to allocate memory. This will then cause append() to copy the data from the other string instead of using copy on write. Task-number: oss-fuzz-24347 Pick-to: 5.12 5.15 Change-Id: I581bd109f9b973e1c70b7b41b1f610a2ad5725b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix a number of qdoc warnings related to deprecationFriedemann Kleint2020-07-241-117/+0
| | | | | | | Remove obsolete documentation. Change-Id: Iaf4b6f9852a883dea0f256c5c89e74f6ebbe85f3 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix QXmlStreamPrivateTagStack uninitialized memberSander Visser2020-07-161-0/+1
| | | | | | | | Make sure to init tagsDone from constructor. Avoid relying on QXmlStreamReaderPrivate::init(). Change-Id: I40c08dd370b0ad519e2d6ebc23b8a906c836508e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix missing member in QXmlStreamReaderPrivate::initSander Visser2020-07-161-0/+1
| | | | | | | Add missing lastAttributeIsCData Change-Id: I66429d35da0451eefe8d14e031306b16df910d0f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-291-6/+6
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Get rid of some QTextCodec leftoversLars Knoll2020-05-141-3/+0
| | | | | | | There's no real dependency to QTextCodec in those files anymore. Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of the QTextCodec dependency in QXmlStreamReaderLars Knoll2020-05-141-77/+26
| | | | | | | | | | | | Use QStringDecoder to convert the data instead. [ChangeLog][Important Behavior Changes] QXmlStreamWriter always encodes XML in UTF-8, and QXmlStreamReader is limited to XML files encoded in Unicode encodings (UTF-8, UTF-16 and UTF-32) and latin1 (ISO-8859-1). Change-Id: I10da612b951f4312ddaf63a89587697777dd8dc1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Always write XML documents as UTF-8Lars Knoll2020-05-141-138/+20
| | | | | | | | | | | Remove support for setting a codec different from UTF-8 for writing XML files. All XML readers today can handle UTF-8, and there is no reason anymore to write a file in a different encoding. Change-Id: If89fb2d2474a2b55644d9bed7473c11ad91033eb Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* QXmlStreamReader: port Private::put...() to QStringViewMarc Mutz2020-05-111-12/+16
| | | | | | | | This enables the use of QChar::fromUcs4() instead of QString::fromUcs4() in a call to putStringLiteral(). Change-Id: I6ed933cc92bfbb70ed2b168b7deeeb466bc6bfeb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStreamSimpleStack: port to qsizetypeMarc Mutz2020-05-111-15/+15
| | | | | Change-Id: Ie4ea7ca83dc1870d1a4a4cfbe4447b5d971b33bf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStream: use even more ranged for loopsMarc Mutz2020-05-111-4/+21
| | | | | | | | | Write a small range adapter that maps begin() to rbegin() and end() to rend() of the underlying range, use it to replace indexed reverse loops with ranged for ones. Change-Id: I5498a23106b0432ce885e72e5e3912910f50b5c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStream: use more ranged for loopsMarc Mutz2020-05-101-18/+11
| | | | | | | | | More compact and isolates against decltype(size()) issues. Had to make QXmlStreamSimpleStack iterable. Change-Id: Icfa7b2ab09995c7a442fd8a5b2f5d6ce90120822 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStreamReader: fix a qint64 -> int truncationMarc Mutz2020-05-101-2/+2
| | | | | | | | | QIODevice::read() returns qint64, not int, and nbytesread is qint64, too. Pick-to: 5.15 Change-Id: I6d41c5c656336a95bb115b461282e9f247493c25 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Read XML as utf-8 not latin1 if we don't have codecsLars Knoll2020-05-011-6/+6
| | | | | | | | | | | 99.5% of all XML documents in the world are encoded in utf-8, not in latin1. Also fix the tr() methods to use fromUtf8() in line with the Qt6 policy that source code should be in utf8. Change-Id: Ie8744786185de839bfa5c9853b7bc36e36af293a Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* Doc: Remove mentioning of QXmlSimpleReader from QXmlStreamReaderKai Koehne2020-04-241-6/+4
| | | | | | Pick-to: 5.15 Change-Id: Ieba073c21f666421ab519089e0976880e67ad0b1 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add an expansion limit for entitiesLars Knoll2020-02-261-0/+36
| | | | | | | | | | | | | | | | | | | | | Recursively defined entities can easily exhaust all available memory. Limit entity expansion to a default of 4096 characters to avoid DoS attacks when a user loads untrusted content. Added a setter and getter to allow modifying the expansion limit. [ChangeLog][QtCore][QXmlStream] QXmlStreamReader does now by default limit the expansion of entities to 4096 characters. Documents where a single entity expands to more characters than the limit are not considered well formed. The limit is there to avoid DoS attacks through recursively expanding entities when loading untrusted content. The limit can be changed through the QXmlStreamReader::setEntityExpansionLimit() method. Fixes: QTBUG-47417 Change-Id: I94387815d74fcf34783e136387ee57fac5ded0c9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QXmlStreamReader: fix memory leakGiuseppe D'Angelo2020-01-231-3/+4
| | | | | | | | | | | | | On some inputs a QXmlStreamReaderPrivate may allocate another QXmlStreamReaderPrivate as its entityResolver. Which, recursively, may allocate yet another one. This "chain" of QXmlStreamReaderPrivate objects was managed using raw pointers, and a leak was possible by resetting one of these pointers to nullptr without freeing the corresponding object. Change-Id: I2c6e1f023a2ed68b2b1857db25c53cce7f6bd3e7 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QXmlStreamReader: early return in case of malformed attributesGiuseppe D'Angelo2020-01-231-2/+5
| | | | | | | | There's no point at keep raising errors after encountering the first malformed attribute. Change-Id: Idb37e577ea96c3bd850b3caf008fe3ecd57dd32e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from QStringViewLiteral to u""Marc Mutz2019-07-291-2/+2
| | | | | | | | | Now that all our supported compilers know char16_t, we no longer need QStringViewLiteral, whose only purpose in life was to turn u"" into L"" for MSVC < 2015. Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Be less laissez-faire with implicit conversions to QCharMarc Mutz2019-07-091-1/+1
| | | | | | | | | | | | | QChar currently is convertible from nearly every integral type. This is bad code hygiene and should be fixed come Qt 6. The present patch is the result of compile fixes from marking these constructors explicit. As is clear from the distribution of fixes, only low-level string handling code used these implicit conversions, an indication that they're not in widespread use elsewhere. Change-Id: Ief5336f21e6d181e03ab92893b3d13a14adc7cb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-13/+13
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Compile when bumping the Qt version to 6.0Lars Knoll2019-05-021-1/+11
| | | | | Change-Id: Idae1a2df144598df3921ef9a12e0e0b740fd723d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QtCore: replace 0 with \nullptr in documentationChristian Ehrlicher2019-01-281-4/+4
| | | | | | | | | | | Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: I101a61f5fad71cadb73bba9a8fd5dce6cc0836d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-091-20/+22
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/Makefile.unix src/gui/text/qtextdocument.cpp src/gui/text/qtextdocument.h Change-Id: Iba26da0ecbf2aa4ff4b956391cfb373f977f88c9
| * Modernize the "textcodec" featureLiang Qi2018-11-071-20/+22
| | | | | | | | | | | | | | | | | | Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Fix QXmlStreamWriter xmlns attribute placementhjk2018-09-281-1/+1
|/ | | | | | | | | Done-by: Eugenio Rustico Change-Id: Ibd6aa6cc8be9090a4fad4f96628086d8a498b8e0 Fixes: QTBUG-63434 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Add missing full stops in briefsPaul Wicking2018-06-211-1/+1
| | | | | | Task-number: QTBUG-68933 Change-Id: I3f2a9f8c562f9a44bb32bddd31d75abbfe6de04d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: explain how QXmlStream{Reader,Writer} deal with encoding in QStringThiago Macieira2018-01-261-0/+20
| | | | | | | | | | | QXmlStreamWriter does not: it just writes the QString inputs to the output. QXmlStreamReader does: it first converts the QString to UTF-8 and stores locally. Then it tries to decode using the XML encoding header. Change-Id: I39332e0a867442d58082fffd1503d7652cb9fbff Reviewed-by: Martin Smith <martin.smith@qt.io>
* Create corelib/serialization and move existing file formats into itThiago Macieira2018-01-261-0/+4014
This is in preparation to adding CBOR support. We don't need yet another dir for CBOR and placing it in src/corelib/json is just wrong. Change-Id: I9741f017961b410c910dfffd14ffb9d870340fa6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>