From 109bd56f39fd570f9e006a21d067dc3b284e950d Mon Sep 17 00:00:00 2001 From: Abs62 Date: Wed, 31 Jan 2018 18:38:16 +0300 Subject: [PATCH] Wiki: Fix work with headwords containing the '+' sign --- mediawiki.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mediawiki.cc b/mediawiki.cc index 8a433db0..bbeceee0 100644 --- a/mediawiki.cc +++ b/mediawiki.cc @@ -125,7 +125,11 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str, GD_DPRINTF( "request begin\n" ); QUrl reqUrl( url + "/api.php?action=query&list=allpages&aplimit=40&format=xml" ); - Qt4x5::Url::addQueryItem( reqUrl, "apfrom", gd::toQString( str ) ); +#if IS_QT_5 + Qt4x5::Url::addQueryItem( reqUrl, "apfrom", gd::toQString( str ).replace( '+', "%2B" ) ); +#else + reqUrl.addEncodedQueryItem( "apfrom", QUrl::toPercentEncoding( gd::toQString( str ) ) ); +#endif netReply = mgr.get( QNetworkRequest( reqUrl ) ); @@ -266,7 +270,11 @@ void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr, QUrl reqUrl( url + "/api.php?action=parse&prop=text|revid&format=xml&redirects" ); - Qt4x5::Url::addQueryItem( reqUrl, "page", gd::toQString( str ) ); +#if IS_QT_5 + Qt4x5::Url::addQueryItem( reqUrl, "page", gd::toQString( str ).replace( '+', "%2B" ) ); +#else + reqUrl.addEncodedQueryItem( "page", QUrl::toPercentEncoding( gd::toQString( str ) ) ); +#endif QNetworkReply * netReply = mgr.get( QNetworkRequest( reqUrl ) );