MediaWiki engine: Fix resource urls for SSL connection (issue #609)

This commit is contained in:
Abs62 2015-06-24 17:50:14 +03:00
parent 1d16b8e282
commit 8717a56910
2 changed files with 8 additions and 7 deletions

View file

@ -369,10 +369,11 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
// audio url // audio url
articleString.replace( QRegExp( "<a\\s+href=\"(//upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)" ), articleString.replace( QRegExp( "<a\\s+href=\"(//upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)" ),
QString::fromStdString( addAudioLink( "\"http:\\1\"",this->dictPtr->getId() )+ "<a href=\"http:\\1" ) ); QString::fromStdString( addAudioLink( string( "\"" ) + wikiUrl.scheme().toStdString() + ":\\1\"",
this->dictPtr->getId() ) + "<a href=\"" + wikiUrl.scheme().toStdString() + ":\\1" ) );
// Add "http:" to image source urls // Add url scheme to image source urls
articleString.replace( " src=\"//", " src=\"http://" ); articleString.replace( " src=\"//", " src=\"" + wikiUrl.scheme() + "://" );
//fix src="/foo/bar/Baz.png" //fix src="/foo/bar/Baz.png"
articleString.replace( "src=\"/", "src=\"" + wikiUrl.toString() +"/" ); articleString.replace( "src=\"/", "src=\"" + wikiUrl.toString() +"/" );
@ -380,9 +381,9 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
articleString.replace( QRegExp( "<a\\shref=\"/([\\w\\.]*/)*" ), "<a href=\"" ); articleString.replace( QRegExp( "<a\\shref=\"/([\\w\\.]*/)*" ), "<a href=\"" );
//fix audio //fix audio
articleString.replace( QRegExp("<button\\s+[^>]*(upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)[^>]*>\\s*<[^<]*</button>"), articleString.replace( QRegExp( "<button\\s+[^>]*(upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)[^>]*>\\s*<[^<]*</button>"),
QString::fromStdString(addAudioLink("\"http://\\1\"",this->dictPtr->getId())+ QString::fromStdString(addAudioLink( string( "\"" ) + wikiUrl.scheme().toStdString() + "://\\1\"", this->dictPtr->getId() ) +
"<a href=\"http://\\1\"><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\"></a>")); "<a href=\"" + wikiUrl.scheme().toStdString() + "://\\1\"><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\"></a>" ) );
// In those strings, change any underscores to spaces // In those strings, change any underscores to spaces
for( ; ; ) for( ; ; )
{ {

View file

@ -49,7 +49,7 @@ bool WebMultimediaDownload::isAudioUrl( QUrl const & url )
{ {
// Note: we check for forvo sound links explicitly, as they don't have extensions // Note: we check for forvo sound links explicitly, as they don't have extensions
return url.scheme() == "http" && ( return ( url.scheme() == "http" || url.scheme() == "https" ) && (
Filetype::isNameOfSound( url.path().toUtf8().data() ) || url.host() == "apifree.forvo.com" ); Filetype::isNameOfSound( url.path().toUtf8().data() ) || url.host() == "apifree.forvo.com" );
} }