Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
6.7.0
-
None
-
038c199d5 (dev), 82b2436d4 (6.7)
Description
reproduce steps:
1. create u.cpp:
u.cpp
#include <QMimeData> #include <QUrl> int main(void){ QMimeData m; m.setData("text/uri-list","https://example.com/\nhttps://example.net/\nhttps://example.org/"); QList<QUrl> urls=m.urls(); QByteArray b; for(size_t i=0,len=urls.size();i<len;++i){ b.append(urls[i].toEncoded()); b.append('\n'); } fwrite(b.constData(),1,b.size(),stdout); }
2. run:
g++ \ u.cpp \ -o u \ -O0 \ -ggdb \ -I/usr/include/x86_64-linux-gnu/qt6 \ -I/usr/include/x86_64-linux-gnu/qt6/QtCore \ -lQt6Core
3. run:
./u
real output:
https://example.com/ https://example.net/
expected output:
https://example.com/ https://example.net/ https://example.org/
I think bug is in this function in qmimedata.cpp (while loop body never runs if '\n' not found):
static QList<QVariant> dataToUrls(QByteArrayView text) { QList<QVariant> list; qsizetype newLineIndex = -1; qsizetype from = 0; const char *begin = text.data(); while ((newLineIndex = text.indexOf('\n', from)) != -1) { const auto bav = QByteArrayView(begin + from, begin + newLineIndex).trimmed(); if (!bav.isEmpty()) list.push_back(QUrl::fromEncoded(bav)); from = newLineIndex + 1; if (from >= text.size()) break; } return list; }