mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
Websites: Fix loading some CSS (from url with query)
This commit is contained in:
parent
cd57031d44
commit
79f05a23c8
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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() );
|
||||
|
||||
|
|
9
qt4x5.hh
9
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
|
||||
|
|
Loading…
Reference in a new issue