diff --git a/article_netmgr.cc b/article_netmgr.cc index f4093903..687535f9 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -249,7 +249,6 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op, localReq.setUrl( newUrl ); } - if ( op == GetOperation ) { if ( localReq.url().scheme() == "qrcx" ) @@ -472,7 +471,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( } try { - return dictionaries[ x ]->getResource( Qt4x5::Url::path( url ).mid( 1 ).toUtf8().data() ); + return dictionaries[ x ]->getResource( Qt4x5::Url::fullPath( url ).mid( 1 ).toUtf8().data() ); } catch( std::exception & e ) { diff --git a/mainwindow.cc b/mainwindow.cc index 2ecc86b1..a016fa9f 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3584,18 +3584,28 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri vector< pair< QUrl, QString > > & downloadResources ) { int pos = 0; + int queryNom = 1; while ( ( pos = rx.indexIn( html, pos ) ) != -1 ) { QUrl url( rx.cap( 1 ) ); QString host = url.host(); - QString resourcePath = Qt4x5::Url::path( url ); + QString resourcePath = Qt4x5::Url::fullPath( url ); if ( !host.startsWith( '/' ) ) host.insert( 0, '/' ); if ( !resourcePath.startsWith( '/' ) ) resourcePath.insert( 0, '/' ); + // Replase query part of url (if exist) + int n = resourcePath.indexOf( QLatin1Char( '?' ) ); + if( n >= 0 ) + { + QString q_str = QString( "_q%1" ).arg( queryNom ); + resourcePath.replace( n, resourcePath.length() - n, q_str ); + queryNom += 1; + } + QCryptographicHash hash( QCryptographicHash::Md5 ); hash.addData( rx.cap().toUtf8() ); diff --git a/qt4x5.hh b/qt4x5.hh index fdc6ab44..5aa093fd 100644 --- a/qt4x5.hh +++ b/qt4x5.hh @@ -120,6 +120,15 @@ inline void removeQueryItem( QUrl & url, QString const & key ) #endif } +inline QString fullPath( QUrl const & url ) +{ +#if IS_QT_5 + return url.toString( QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemovePort | QUrl::FullyDecoded ); +#else + return url.toString( QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemovePort ); +#endif +} + inline void setQueryItems( QUrl & url, QList< QPair< QString, QString > > const & query ) { #if IS_QT_5