QDesktopServices: don't use openDocument if the URL has a query

[ChangeLog][QtGui][QDesktopServices] Fixed a bug that caused
QDesktopServices::openUrl() to discard a query when opening a local file
URL that contained a query but no fragment.

Pick-to: 6.9 6.8
Fixes: QTBUG-133663
Change-Id: Ie8fa190036417f590540fffdcf03e53f3c99b38f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Thiago Macieira 2025-02-11 08:34:29 -08:00
parent 0cc41083c3
commit aad0ab897f

View File

@ -177,9 +177,9 @@ bool QDesktopServices::openUrl(const QUrl &url)
qWarning("The platform plugin does not support services.");
return false;
}
// We only use openDocument if there is no fragment for the URL to
// We only use openDocument if there is no fragment or query for the URL to
// avoid it being lost when using openDocument
if (url.isLocalFile() && !url.hasFragment())
if (url.isLocalFile() && !url.hasFragment() && !url.hasQuery())
return platformServices->openDocument(url);
return platformServices->openUrl(url);
}