From add736e0ee846bb8036f6fdce3ca5663f149081c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 6 Nov 2014 12:03:28 -0500 Subject: [PATCH] Fix some QUrl percent encoding problems --- src/libtomahawk/utils/TomahawkUtils.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/utils/TomahawkUtils.cpp b/src/libtomahawk/utils/TomahawkUtils.cpp index b5585c0e2..adf6fafb4 100644 --- a/src/libtomahawk/utils/TomahawkUtils.cpp +++ b/src/libtomahawk/utils/TomahawkUtils.cpp @@ -950,7 +950,13 @@ percentEncode( const QUrl& url ) { QByteArray data = url.toEncoded(); - data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid. + // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid. It also doesn't encode : or ; which it should, so be safer here in general. + data.replace( "'", "%27" ); + data.replace( ".", "%2E" ); + data.replace( "*", "%2A" ); + data.replace( ":", "%3A" ); + data.replace( ";", "%3B" ); + data.replace( "%20", "+" ); return data; @@ -960,11 +966,18 @@ percentEncode( const QUrl& url ) QByteArray encodedQuery( const QUrl& url ) { + QByteArray data; #if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) - return url.query(QUrl::FullyEncoded).toUtf8(); + data = url.query(QUrl::FullyEncoded).toUtf8(); #else - return url.encodedQuery(); + data = url.encodedQuery(); #endif + data.replace( "'", "%27" ); + data.replace( ".", "%2E" ); + data.replace( "*", "%2A" ); + data.replace( ":", "%3A" ); + data.replace( ";", "%3B" ); + return data; } } // ns