qt5base-lts/tests/auto/corelib
Tor Arne Vestbø 4cb614c7ab Apple OS: Handle QSetting strings with embedded zero-bytes
Saving strings with embedded zero-bytes (\0) as CFStrings would
sometimes fail, and only write the part of the string leading
up to the first zero-byte, instead of all the way to the final
zero-terminator. This bug was revealed by the code-path that
falls back to storing e.g. QTime as strings, via the helper
method QSettingsPrivate::variantToString().

We now use the same approach as on platforms such as Windows
and WinRT, where the string produced by variantToString() is
checked for null-bytes, and if so, stored using a binary
representation instead of as a string. For our case that
means we fall back to CFData when detecting the null-byte.

To separate strings from regular byte arrays, new logic has
been added to variantToString() that wraps the null-byte
strings in @String(). That way we can implement a fast-path
when converting back from CFData, that doesn't go via the
slow and lossy conversion via UTF8, and the resulting QVariant
will be of type QVariant::ByteArray. The reason for using
UTF-8 as the binary representation of the string is that
in the case of storing a QByteArray("@foo") we need to
still be able to convert it back to the same byte array,
which doesn't work if the on-disk format is UTF-16.

Task-number: QTBUG-56124
Change-Id: Iab2f71cf96cf3225de48dc5e71870d74b6dde1e8
Cherry-picked: 764f5bf48c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-10-18 14:35:08 +00:00
..
animation Extend tst_QPauseAnimation::pauseAndPropertyAnimations blacklist 2015-06-20 15:25:58 +00:00
codecs Fix utf8->utf16 BOM/ZWNBSP decoding. 2015-12-21 09:56:49 +00:00
global Fix qSetMessagePattern to have many time/backtrace parts 2016-03-25 11:03:43 +00:00
io Apple OS: Handle QSetting strings with embedded zero-bytes 2016-10-18 14:35:08 +00:00
itemmodels tst_QStringListModel: don't leak memory when tests fail 2016-08-12 08:28:07 +00:00
json Update testdata 2016-02-17 04:50:50 +00:00
kernel QObject test: check that throwing from a child's constructor works 2016-09-26 04:47:06 +00:00
mimetypes QMimeType: use default locale rather than system locale 2016-08-24 20:30:13 +00:00
plugin Fix qplugin autotest on Windows 2016-06-08 19:40:29 +00:00
statemachine Merge remote-tracking branch 'origin/5.5' into 5.6 2016-01-19 10:03:01 +01:00
thread tst_QAtomicInteger: fix UBs (signed overflow) 2016-03-24 16:16:15 +00:00
tools QLatin1String: Fix UB (nullptr passed) in relational operators 2016-09-15 10:10:28 +00:00
xml QtCore: Fix QXmlStreamReader for invalid characters in XML 1.0 2016-07-17 14:54:36 +00:00
corelib.pro iOS: Enable building of basic tests 2014-01-22 12:35:17 +01:00