1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Fixed Content-Disposition parser to support also filenames not enclosed

with quotes ("filename")
This commit is contained in:
nowrep 2012-02-15 14:39:46 +01:00
parent 04ec0cfcef
commit 8d357f79da

View File

@ -238,11 +238,14 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply)
reg.indexIn(value); reg.indexIn(value);
path = QUrl::fromPercentEncoding(reg.cap(1).toUtf8()).trimmed(); path = QUrl::fromPercentEncoding(reg.cap(1).toUtf8()).trimmed();
} }
else if (value.contains("filename=\"")) { else if (value.contains("filename=")) {
QRegExp reg("filename=\"(.*)\""); QRegExp reg("filename=([^;]*)");
reg.setMinimal(true);
reg.indexIn(value); reg.indexIn(value);
path = reg.cap(1).trimmed(); path = reg.cap(1).trimmed();
if (path.startsWith("\"") && path.endsWith("\"")) {
path = path.mid(1, path.length() - 2);
}
} }
} }
if (path.isEmpty()) { if (path.isEmpty()) {