QMimeData: fix setData on URI list without ending CRLF
Commit 8d127c57376e48dd49afe62cfb8e714d26759a69 refactored this code from QByteArray::split to manually iterate over the list (and QStringTokenizer doesn't work for QByteArray), so we missed the last element in the iteration. Fixes: QTBUG-124580 Change-Id: I455fe22ef4ad4b2f9b01fffd17c867f6ed350af7 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 038c199d59ff5e9e16fe2a010f3f1f55764cf5ba) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
2bb4e23cc4
commit
82b2436d4c
@ -90,6 +90,11 @@ static QList<QVariant> dataToUrls(QByteArrayView text)
|
||||
if (from >= text.size())
|
||||
break;
|
||||
}
|
||||
if (from != text.size()) {
|
||||
const auto bav = QByteArrayView(begin + from, text.end()).trimmed();
|
||||
if (!bav.isEmpty())
|
||||
list.push_back(QUrl::fromEncoded(bav));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,14 @@ void tst_QMimeData::data() const
|
||||
QCOMPARE(mimeData.data("text/markdown"), QByteArray("vikings"));
|
||||
QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas"));
|
||||
QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates"));
|
||||
|
||||
// URI list
|
||||
QByteArray list = "https://example.com/\r\nhttps://example.net/\r\nhttps://example.org/\r\n";
|
||||
mimeData.setData("text/uri-list", list);
|
||||
QCOMPARE(mimeData.data("text/uri-list"), list);
|
||||
|
||||
mimeData.setData("text/uri-list", list.chopped(2)); // without the ending CRLF
|
||||
QCOMPARE(mimeData.data("text/uri-list"), list);
|
||||
}
|
||||
|
||||
void tst_QMimeData::formats() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user