summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-05-16 17:24:28 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-05-18 09:33:41 +0200
commita32742936d6da1167c5b8200ef8b2827daf4c13f (patch)
tree816759dc2ccd5650a8e221a5114851377578d150
parent26203fd60631a091739cbba7cc7220429e1b9d21 (diff)
tdf#137639 qt: UTF-16-encode mime data for "text/plain;charset=utf-16"
Return a `QVariant` from a `QByteArray` containing the UTF-16-encoded characters when mime data for mime type "text/plain;charset=utf-16" is requested in `QtMimeData::retrieveData`, rather than a `QVariant` created from a a `QString`, to ensure that UTF-16 encoded data is actually used in the end. While `QString` uses UTF-16 encoding itself, `QMimeDataPrivate::retrieveTypedData` from the Qt library would convert the retrieved `QString` data to UTF-8 [1], resulting in a mismatch because UTF-8 encoded data would actually be returned when UTF-16-encoded one has been requested. This gets called as follows: 0 QtMimeData::retrieveData 1 QMimeDataPrivate::retrieveTypedData 2 QMimeData::data 3 QtMimeData::deepCopy [1] https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qmimedata.cpp?h=6.3.0#n212 Change-Id: I3db1476838336682584145fb43d397c8eed29ce2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134456 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit 6fc3ec85a32cd70216b4bbf21e479b4fc32a38dc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134451 Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
-rw-r--r--vcl/qt5/QtTransferable.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/qt5/QtTransferable.cxx b/vcl/qt5/QtTransferable.cxx
index 1ab07dbb6224..24073c9fd792 100644
--- a/vcl/qt5/QtTransferable.cxx
+++ b/vcl/qt5/QtTransferable.cxx
@@ -339,6 +339,11 @@ QVariant QtMimeData::retrieveData(const QString& mimeType, QMetaType) const
aByteArray = QByteArray(reinterpret_cast<const char*>(aLocaleString.getStr()),
aLocaleString.getLength());
}
+ else if (bWantUTF16)
+ {
+ aByteArray = QByteArray(reinterpret_cast<const char*>(aString.getStr()),
+ aString.getLength() * 2);
+ }
else
return QVariant(toQString(aString));
}