qt5base-lts/tests/auto
Sona Kurazyan 1df02b5f98 Fix conversions to JSON from QVariant
After reimplementing Qt JSON support on top of CBOR, there were
unintended behavior changes when converting QVariant{, List, Map} to
QJson{Value, Array, List} due to reusing the code for converting
QVariant* types to CBOR types, and from CBOR types to corresponding JSON
types. In particular, conversions from QVariant containing QByteArray to
JSON has been affected: according to RFC 7049, when converting from
CBOR to JSON, raw byte array data must be encoded in base64url when
converting to a JSON string. As a result QVariant* types containing
QByteArray data ended up base64url-encoded when converted to JSON,
instead of converting using QString::fromUtf8() as before.

There were also differences when converting QRegularExpression.

Reverted the behavior changes by adding a flag to internal methods for
converting CBOR to JSON, to distinguish whether the conversion is done
from QVariant* or CBOR types. These methods now will fall back to the old
behavior, if the conversion is done using QJson*::fromVariant*().

Additionally fixed QJsonValue::fromVariant conversion for NaN and
infinities: they should always convert to QJsonValue::Null. This works
correctly when converting from variant to QJsonArray/QJsonObject, but has
been wrong for QJsonValue.

Added more tests to verify the expected behavior.

[ChangeLog][Important Behavior Changes] Restored pre-5.15.0 behavior
when converting from QVariant* to QJson* types. Unforeseen consequences
of changes in 5.15.0 caused QByteArray data to be base64url-encoded; the
handling of QRegularExpression was also unintentionally changed. These
conversions are now reverted to the prior behavior. Additionally fixed
QJsonValue::fromVariant conversions for NaN and infinities: they should
always convert to QJsonValue::Null.

Fixes: QTBUG-84739
Change-Id: Iaee667d00e5363906eedbb67948b7b39c9d0bc78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-13 19:36:58 +02:00
..
cmake CMake: Fix configuration of CMake tests in-build-tree 2020-07-20 18:12:23 +02:00
concurrent CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
corelib Fix conversions to JSON from QVariant 2020-08-13 19:36:58 +02:00
dbus Long Live QMap as a refcounted std::map! 2020-08-06 19:15:39 +02:00
gui Restrict QVariant::isNull() behavior 2020-08-13 08:48:32 +02:00
guiapplauncher Fix path to examples part of tst_GuiAppLauncher 2015-02-13 07:28:15 +00:00
installed_cmake Add a unit test for testing Qt in its install location. 2013-07-02 23:08:54 +02:00
network QDecompressHelper: Change order of encodings 2020-08-12 08:27:09 +00:00
opengl CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
other Disable warning about self-move and self-assign-overload 2020-07-26 18:06:34 +02:00
printsupport CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
shared QWindowsFontDatabase: Check preferred family names for all fonts 2019-11-29 09:31:21 +01:00
sql Restrict QVariant::isNull() behavior 2020-08-13 08:48:32 +02:00
testlib testlib: Add start time and test duration to JUnit XML 2020-07-24 00:52:01 +02:00
tools cmake support for tst_moc 2020-08-10 12:59:46 +02:00
widgets Use the new support for comparisons in QMetaType for QVariant 2020-08-13 08:48:03 +02:00
xml Disable deprecation warnings in some tests 2020-07-29 14:33:23 +02:00
.prev_CMakeLists.txt CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
auto.pro CMake: Get tests/auto/cmake tests working 2020-07-17 09:43:04 +02:00
CMakeLists.txt CMake: Get tests/auto/cmake tests working 2020-07-17 09:43:04 +02:00
network-settings.h Revert "QAbstractSocket: deprecate 'error' member-function" 2020-02-26 23:07:52 +03:00