Fix for url encoding in QDesktopServices::openUrl().

URLs containing spaces (encoded) couldnt be opened using QDesktopServices::openUrl() -method.
This is a regression as it works for 4.8,

Using url.toEncoded() instead of url.toString() which removed percent encoding.

The NSUrl uses RFC 2396 for parsing, and according to the documentation,
of 2.4. Escape Sequences - Data must be escaped if it does not have a
representation using an unreserved character;
And as a space does not have a representation using unreserved character it needs to be
escaped.

Example: Using this url, http://www.google.com/search?q=testme%20withspace
url.toString() returns  "http://www.google.com/search?q=testme withspace"
and url.toEncoded() returns, http://www.google.com/search?q=testme%20withspace" which is
also the expected result.

Task-number: QTBUG-29124
Change-Id: Ieed3d4cfb689b9311f6cf21e5098a1e70256ab03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Indrajit Tapadar 2013-01-23 13:08:20 +01:00 committed by The Qt Project
parent 3bee02c1ca
commit f6c5452d97

View File

@ -55,7 +55,7 @@ bool QCocoaServices::openUrl(const QUrl &url)
const QString scheme = url.scheme();
if (scheme.isEmpty())
return openDocument(url);
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toString())]];
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:QT_PREPEND_NAMESPACE(QCFString::toNSString)(url.toString(QUrl::FullyEncoded))]];
}
bool QCocoaServices::openDocument(const QUrl &url)