summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge "Merge remote-tracking branch 'origin/5.11' into dev" into ↵Liang Qi2018-08-071-1/+1
|\ \ | | | | | | | | | refs/staging/dev
| * | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-071-1/+1
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/corelib/doc/src/objectmodel/signalsandslots.qdoc src/plugins/platforms/cocoa/qcocoamenuloader.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp tests/auto/gui/image/qimage/tst_qimage.cpp Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I9bd24ee9b00d4f26c8f344ce3970aa6e93935ff5
| | * QJsonDocument: Make emptyObject an objectJüri Valdmann2018-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A default-constructed QJsonObject has no data payload, it is only a pair of null pointers. So, when it becomes necessary to 'materialize' such an object, a special global emptyObject constant is used as the substitute payload. There is a small problem with this global constant though, namely that it's is_object flag is unset. In other words, the emptyObject is not an object, but an array. Fix by setting the is_object flag on emptyObject. The example code in the bug report QJsonObject parent; QJsonObject child; parent["child"] = child; // 1 child = parent["child"].toObject(); // 2 child["test"] = "test"; // 3 runs into this problem on line 1. Inserting the default-constructed child means inserting a copy of emptyObject. On line 2 a pointer to this copy of emptyObject is retrieved and cast to an object. But it's not an object, it's an array, so things go wrong hereafter. Specifically, on line 3, two inserts are performed, one from operator[] and one from operator=. Each insert increments a compaction counter. The second insert triggers compaction (QJsonObject::insert calls Value::requiredStorage calls Data::compact) and compaction branches based on the is_object flag. Replacing line 3 with child.insert("test", "test"); causes the example to appear to work since compaction is not triggered and the JSON serializer does not look at the is_object flag. Still, any further insert() calls would trigger compaction and memory corruption. Task-number: QTBUG-69626 Change-Id: I8bd5174dce95998bac479c4b4ffea70bca1a4d04 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | qdoc: Fix \fn commands for QCborxxx member functionsMartin Smith2018-08-072-12/+13
|/ / | | | | | | | | | | | | | | | | | | Severa qdoc function comments had incorrect signatures. This update corrects them to match the declarations in the header file. A \keyword command was also added for linking to the generic algorithms header file page. Change-Id: I997f7f2c7e4d0c3fcd269ee2c89a2836fecd4927 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborValue diagnostics: Properly escape stringsThiago Macieira2018-08-031-5/+71
| | | | | | | | | | | | | | | | | | I'm intentionally not testing improperly-paired surrogates, since those can't be encoded in CBOR. Change-Id: I0d3cc366baaa49f3ad28fffd154240287ce34c22 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge "Merge branch '5.11' into dev" into refs/staging/devEdward Welbourne2018-07-313-1/+4
|\ \
| * | Merge branch '5.11' into devEdward Welbourne2018-07-313-1/+4
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/library/qmakebuiltins.cpp src/plugins/platforms/windows/qwindowstabletsupport.h src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/widgets/styles/qstylesheetstyle.cpp tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp Done-With: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I000b0eb3cea2a5c7a99b95732bfdd41507cf916e
| | * Doc: Add since version for QJsonDocument::toJson()Paul Wicking2018-07-231-0/+1
| | | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-69527 Change-Id: I10df9cc2d6fa2080e07d68b78c6220500f459380 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
| | * Doc: Correct typo from decoded to encodedPaul Wicking2018-07-211-1/+1
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-62081 Change-Id: Ia07b43445661d66ef0e8fe51d8d022bd5d803327 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Doc: Add since version for QJson method and enumPaul Wicking2018-07-192-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | QJsonValue::toInt() introduced in 5.2, 7372c6cf9d4 QJsonDocument::JsonFormat introduced in 5.1, 4bb5566632e Task-number: QTBUG-69527 Change-Id: Idb9df959f82fe7061e0afe2109f1ca34a4451a5f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | | QCborValue: move the toDiagnosticNotation() function to its own fileThiago Macieira2018-07-304-225/+284
|/ / | | | | | | | | | | | | | | | | | | If we ever need to add QCborValue to the bootstrap library, it's unlikely that we'll need this part. And by splitting it, I can make the code handle more cases, that hadn't been properly handled before. Change-Id: I2f630efbbce54f14bfa9fffd154160c0ad893695 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborValue: Disable support for spaceship operatorThiago Macieira2018-07-293-5/+5
| | | | | | | | | | | | | | | | | | __has_include(<compare>) is not the correct way to detect this feature, since that's a library header and may be provided by an implementation (libc++) before the compiler supports the syntax. Change-Id: I80aae0d068974d83b6c0fffd1544c8e558e2446b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Add QTextStream operators for QStringViewFriedemann Kleint2018-07-202-0/+16
| | | | | | | | | | Change-Id: I72d597fa21521a04b7f7c0e41bd45ee9dabb6222 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Update TinyCBOR to 1b233087a6e6b6be297e69bfcce5ed36f338c91dThiago Macieira2018-07-181-22/+5
| | | | | | | | | | | | | | | | From the fork at https://github.com/thiagomacieira/tinycbor Change-Id: I117816bf0f5e469b8d34fffd153dc88683051208 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborArray: add const_iterator overloads for insert/erase/extractThiago Macieira2018-07-142-0/+9
| | | | | | | | | | | | | | | | | | They return regular iterators, since the container has been modified. Change-Id: Id59bdd8f1a804b809e22fffd153f92d4460f9b76 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborMap: make take() & remove() efficient if the item isn't thereThiago Macieira2018-07-141-8/+8
| | | | | | | | | | | | | | | | | | By using constFind(), we won't detach if the item isn't there. Both extract() and erase() can take const_iterators. Change-Id: Id59bdd8f1a804b809e22fffd153f92989ef84644 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | CBOR: Use "noexcept" directlyThiago Macieira2018-07-148-49/+49
| | | | | | | | | | | | | | | | | | | | | | All supported compilers support it. Doing this just for the new API. We should do it throughout Qt, but only if it won't interfere with the header review. Change-Id: Id59bdd8f1a804b809e22fffd153f9254688e5152 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | QCborValue: Silence Coverity warning about null-pointer dereferenceThiago Macieira2018-07-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | It's a false positive, since we've checked that the item HasByteData. But it's cheap to rewrite so the warning is silenced. >>> CID 190741: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "this->byteData(idx)". Change-Id: If48c5c2e920c433298f1fffd153f7534be42a30b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborValue/QDebug: restore decimal state after hexThiago Macieira2018-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | Found by Coverity: >>> CID 190746: API usage errors (STREAM_FORMAT_STATE) >>> Changing format state of stream "dbg" for category basefield without later restoring it. Change-Id: If48c5c2e920c433298f1fffd153f74f9bbe7ef29 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | QCborArray & Map: implement move semanticsThiago Macieira2018-07-055-16/+70
| | | | | | | | | | | | | | | | | | | | | | There isn't a lot of efficiency gain, since QCborValue was already refcounted. This saves two atomic operations and an out-of-line call. In the case of QCborValueRef (which includes QCborMap), because we reset the container pointer in inline code, the call to QCborValue::dispose() is also suppressed. Change-Id: Icc2c231dc2c44abdb087fffd1533eaba7a9c70fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QCborValue: refactor extended types so isTag() is trueThiago Macieira2018-07-052-57/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes QCborValue more future compatible, as code written today for tags that QCborValue does not recognize will continue to work if QCborValue gains support for it in the future. This change also obviates the need for reinterpretAsTag(), which I had not written unit tests for as I knew this change was coming. Change-Id: I052407b777ec43f78378fffd15302bdc34f66755 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborMap: Add reserve() to the QHash conversionThiago Macieira2018-07-051-0/+1
| | | | | | | | | | | | Change-Id: Id4c99d74841842cfa442fffd15371720f9566708 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | CBOR: Avoid conflicts with X11 #defines in our enumsMichael Pyne2018-07-043-0/+36
| | | | | | | | | | | | | | | | | | | | Since the .cpp files in the implementation don't actually include the offending X11 headers they don't need the fix. This just adjusts the headers themselves to unbreak the namespace for just long enough to declare the right enums. Change-Id: If33757aa2289f8fe7b81836f9c08b0ad4592bc32 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborValue: implement move semantics for QCbor{Array,Map} constructorsThiago Macieira2018-07-043-0/+12
| | | | | | | | | | | | | | | | Happens a lot because of the implicit conversions. So I made it inline. Change-Id: Icc2c231dc2c44abdb087fffd1533f311b95460b8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborArray & Map: implement efficient take() / extract()Thiago Macieira2018-07-046-10/+166
| | | | | | | | | | | | | | | | | | | | | | | | Questions: 1) should QCborMap::extract return value_type (a pair) instead of just the value? 2) should the both return the iterator to the next element too, like erase()? Change-Id: I052407b777ec43f78378fffd15302a9c14468db3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | CBOR: Complete the conversions between CBOR, JSON and Qt meta typesThiago Macieira2018-07-042-3/+38
| | | | | | | | | | | | Change-Id: I56b444f9d6274221a3b7fffd150d3130db6ef1a0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Metatype: make the Qt CBOR value-like types built-in meta typesThiago Macieira2018-07-041-1/+0
| | | | | | | | | | | | | | | | This change only adds them to the registry and reserves the IDs. The next commit will handle conversions. Change-Id: I56b444f9d6274221a3b7fffd150d2d49f40940c2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | CBOR: Add QDebug operators for the Qt CBOR value-like typesThiago Macieira2018-07-048-0/+217
| | | | | | | | | | | | | | | | | | | | I added a function that returns the string identifiers for QCborKnownTags and QCborSimpleType, in order to facilitate writing a QTest::toString for those types, as neither enum is part of a Q_OBJECT or Q_GADGET class. Change-Id: I56b444f9d6274221a3b7fffd150d2d26a1925c19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-07-022-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/cocoa/qnsview_dragging.mm src/plugins/platforms/ios/qiosinputcontext.mm src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/tools/androiddeployqt/main.cpp Was moved from qttools into qtbase in 5.11. So re-apply 32398e4d here. tests/auto/corelib/global/qlogging/test/test.pro tests/auto/corelib/global/qlogging/tst_qlogging.cpp tests/auto/corelib/io/qfile/tst_qfile.cpp tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp tests/auto/corelib/thread/qthreadstorage/test/test.pro tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp tests/auto/widgets/kernel/qapplication/test/test.pro Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Done-with: Mårten Nordheim <marten.nordheim@qt.io> Done-with: Oliver Wolff <oliver.wolff@qt.io> Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
| * QDataStream: Fix inlining of operator<<,>>() for quint32Friedemann Kleint2018-06-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The inline operators are referenced by the container serialization helper code above the definition, causing g++ 8.1/MinGW to complain: In file included from ..\..\include/QtCore/qdatastream.h:1, from access\qnetworkaccessdebugpipebackend.cpp:41: ..\..\include/QtCore/../../src/corelib/serialization/qdatastream.h:349:21: error: 'QDataStream& QDataStream::operator>>(quint32&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline QDataStream &QDataStream::operator>>(quint32 &i) ^~~~~~~~~~~ ..\..\include/QtCore/../../src/corelib/serialization/qdatastream.h:361:21: error: 'QDataStream& QDataStream::operator<<(quint32)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline QDataStream &QDataStream::operator<<(quint32 i) Declare the operators to be inline to fix this. Task-number: QTBUG-68742 Task-number: QTQAINFRA-2095 Change-Id: Ifa075aff8749df5c7a56148b8b9a0e3ec1e853aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * 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>
* | Add ObjectMode coordinate mode to QGradientEirik Aavitsland2018-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ObjectBoundingMode coordinate mode of QGradient allows specifying the gradient coordinates relative to the object being painted. But if the gradient brush also has a transformation, that transformation is applied in the logical, not object, coordinate space. That behavior is counterintuitive. However, changing it now would break existing code. Instead, we introduce a new coordinate mode enum with the expected behavior, and document the old one as deprecated. This prepares to fix the bugs below in qtsvg, by making it possible to specify the same behavior in Qt as SVG has. [ChangeLog][QtGui][QGradient] Add ObjectMode coordinate mode [ChangeLog][Important Behavior Changes] QDataStream version bumped up to 18 to account for changes in the serialization of QGradient. Task-number: QTBUG-59978 Task-number: QTBUG-67995 Change-Id: I8820a2555359812f3e1a46e37d6ac2cc29a2091d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | QCborValue: store US-ASCII strings as 8-bitThiago Macieira2018-06-182-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | They're easy to convert back to UTF-16, their length is the same, they occupy half the memory and they're easy to encode into CBOR (no transformation necessary). The code was copied from QJsonPrivate::Latin1String::operator=(). Change-Id: I56b444f9d6274221a3b7fffd150c52bcb6c97f37 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborValue: fix warning about shadowing membersThiago Macieira2018-06-183-15/+18
| | | | | | | | | | | | | | | | | | | | | | qcborvalue.h:145:9: error: declaration of 'taggedValue' shadows a member of 'this' [-Werror=shadow] Newer versions of GCC don't warn for variable shadowing a member function. Task-number: QTBUG-68889 Change-Id: I6efb28c3145047559ec0fffd153857b856267d6d Reviewed-by: Liang Qi <liang.qi@qt.io>
* | QCborStreamReader: Fix uninitialized warningLiang Qi2018-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | serialization/qcborstream.cpp: In member function 'QCborStreamReader::StringResult<int> QCborStreamReader::readStringChunk(char*, qsizetype)': serialization/qcborstream.cpp:2845:62: error: 'content' may be used uninitialized in this function [-Werror=maybe-uninitialized] memcpy(ptr, d->buffer.constData() + d->bufferStart + offset, toRead); ^ Task-number: QTBUG-68889 Change-Id: Ieea05672f2fdd7685c2af0e0aa7fa8b281d25618 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QCborValue: add support for QVariant and JSON conversionsThiago Macieira2018-06-087-2/+972
| | | | | | | | | | | | | | Plus QStringList. Change-Id: I39332e0a867442d58082fffd1508dfb9b540af23 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Long live DOM API for CBOR!Thiago Macieira2018-06-089-0/+6639
| | | | | | | | | | | | | | | | | | | | | | | | This is very similar to QJsonDocument, but there's no QCborDocument. QCborValue is that. [ChangeLog][QtCore] Added QCborValue, QCborArray and QCborMap, classes that permit DOM-like access to CBOR data. The API is similar to QJsonValue, QJsonArray and QJsonObject, respectively. Change-Id: I9741f017961b410c910dfffd14ffca50dd8ef3ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | QCborStreamReader: update to the new TinyCBOR zero-copy string APIThiago Macieira2018-06-061-45/+64
| | | | | | | | | | Change-Id: Iab119b62106d40fb8499fffd1510abe5d8f2722a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborStreamReader: use QByteArray directly if possibleThiago Macieira2018-06-061-62/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QIODevice represents considreable overhead, even with just QBuffer, for parsing simple things. Benchmarking showed it was spending 25% of the parsing time inside one QIODevice function or another. So this commit accomplishes two things: 1) it increases the buffer size from 9 bytes to up to 256, which should reduce the number of calls into the QIODevice 2) if the source data is a QByteArray, then use it directly and bypass the QIODevice, thus increasing performance considerably Change-Id: I56b444f9d6274221a3b7fffd150c531c9d28e54b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QCborStreamReader: rewrite read{String,ByteArray}()Thiago Macieira2018-05-301-39/+14
| | | | | | | | | | | | | | | | | | This rewrites _readString_helper() in terms of _readByteArray_helper() (the helper version doesn't do type-checking) and rewrites _readByteArray_helper() in terms of readStringChunk(). Change-Id: Iab119b62106d40fb8499fffd1510aa404d9f3611 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QCborStreamReader: remove the documentation on the validation APIThiago Macieira2018-05-291-7/+0
| | | | | | | | | | | | | | It's not present in this version. Change-Id: I6a540578e810472bb455fffd1532ac4d49d4b994 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Long live QCborStreamReader!Thiago Macieira2018-05-272-13/+1714
| | | | | | | | | | | | | | | | | | | | This is the counterpart of the previous commit. [ChangeLog][QtCore] Added QCborStreamReader and QCborStreamWriter, classes for low-level reading and writing of CBOR streams. Change-Id: Ia0aac2f09e9245339951ffff13c72e4bffdf4a56 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Long live QCborStreamWriter!Thiago Macieira2018-05-274-0/+1497
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CBOR is the Concise Binary Object Representation, a very compact form of binary data encoding that is compatible with JSON. It was created by the IETF Constrained RESTful Environments (CoRE) WG[1] and has since been used in many new RFCs by that group, especially COSE[2], and is meant to be used alongside CoAP[3]. This API is a very simple, thin wrapper around TinyCBOR[4]. See RFC 7049 <http://tools.ietf.org/html/rfc7049>. [1] https://datatracker.ietf.org/wg/core/charter/ [2] https://tools.ietf.org/html/rfc8152 [3] https://tools.ietf.org/html/rfc7252 [4] https://github.com/intel/tinycbor Change-Id: Ia0aac2f09e9245339951ffff13c651cfeab77d3b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-241-23/+20
|\| | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/qt_common.prf src/corelib/tools/qstring.cpp src/plugins/platforms/windows/qwindowsmousehandler.cpp src/widgets/widgets/qmainwindowlayout_p.h Change-Id: I5df613008f6336f69b257d08e49a133d033a9d65
| * QJsonDocument: Avoid overflow of string lengthsJüri Valdmann2018-05-141-23/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The added test case contains the binary JSON equivalent of ["ž"] with the modification that the string's length has been set to INT_MAX. In Value::usedStorage this length is used through the pointer d like so s = sizeof(int) + sizeof(ushort) * qFromLittleEndian(*(int *)d); Because 2 * INT_MAX is UINT_MAX-1, the expression as a whole evaluates to 2, which is considered a valid storage size. However, when converting this binary JSON into ordinary JSON we will attempt to construct a QString of length INT_MAX. Fixed by using String::isValid instead of Value::usedStorage. This method already takes care to avoid the overflow problem. Additionally, I've tried in this patch to clarify the behavior of Value::isValid a bit by writing it in a style that is hopefully more amenable to structural induction. Finally, the test case added in my previous patch had the wrong file extension and is renamed in this one. Task-number: QTBUG-61969 Change-Id: I45d891f2467a71d8d105822ef7eb1a73c3efa67a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QString: add a method to do a conversion to Latin1 without checkingThiago Macieira2018-05-151-25/+7
| | | | | | | | | | | | | | | | | | | | | | If the input is already known to be Latin 1, we don't need to check and merge in question marks. QJsonObject already needed this code, now we can make it more efficient. I'll need the same code in CBOR. Change-Id: Ib48364abee9f464c96c6fffd152e508f078404e5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-05-053-6/+7
|\| | | | | | | Change-Id: Ib58433da04bffb5dfab5486b80f17f39cc4145fa
| * QJsonDocument: Validate also zero-length objectsJüri Valdmann2018-05-041-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The added test case is the binary JSON equivalent of {"a":{"š":null}} with two modifications. First, the length of the string "š" has been corrupted to 0xFFFFFF00. Second and more import, the Base::size field of the inner object has been reset to 0. On its own the first modification would normally trigger a validation error. However, due to the second modification the Value::usedStorage for the inner object evaluates to 0, completely disabling all further validation of the object's contents. Attempting to convert this binary JSON into standard JSON will lead to the JSON writer trying to construct a QString of length 0xFFFFFF00. Fixed by validating also objects with usedStorage == 0. Task-number: QTBUG-61969 Change-Id: I5e59383674dec9be89361759572c0d91d4e16e01 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QJsonDocument: Reject objects containing themselves in binary JSONJüri Valdmann2018-05-041-3/+3
| | | | | | | | | | | | | | | | | | | | The added test case is a binary JSON file describing an array which contains itself. This file passes validation even though attempting to convert it to plain JSON leads to an infinite loop. Fixed by rejecting it in validation. Task-number: QTBUG-61969 Change-Id: Ib4472e9777d09840c30c384b24294e4744b02045 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * QJsonDocument::fromRawData: Fix out-of-bounds accessJüri Valdmann2018-05-042-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This method takes a pointer+size pair, but begins reading through the pointer without first checking the size parameter. Fixed by checking the size parameter. A new test case is added with an empty binary json file. Although the test does not fail under normal conditions, the problem can be detected using valgrind or AddressSanitizer. Task-number: QTBUG-61969 Change-Id: Ie91cc9a56dbc3c676472c614d4e633d7721b8481 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>