mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 03:14:06 +00:00
opt: forbid the page to redirect to audio link url.
This commit is contained in:
parent
45c2bf38bd
commit
ce35085f25
10
utils.hh
10
utils.hh
|
@ -11,6 +11,7 @@
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include "filetype.hh"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
|
@ -240,6 +241,15 @@ inline std::pair< bool, QString > getQueryWord( QUrl const & url )
|
||||||
}
|
}
|
||||||
return std::make_pair( validScheme, word );
|
return std::make_pair( validScheme, word );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isAudioUrl( QUrl const & url )
|
||||||
|
{
|
||||||
|
// Note: we check for forvo sound links explicitly, as they don't have extensions
|
||||||
|
|
||||||
|
return ( url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gdau" )
|
||||||
|
&& ( Filetype::isNameOfSound( url.path().toUtf8().data() ) || url.host() == "apifree.forvo.com" );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,11 @@ void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info)
|
||||||
// emit linkClicked( info.requestUrl() );
|
// emit linkClicked( info.requestUrl() );
|
||||||
// info.block(true);
|
// info.block(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//window.location=audio link
|
||||||
|
if( Utils::Url::isAudioUrl(info.requestUrl()) && info.navigationType()==QWebEngineUrlRequestInfo::NavigationTypeRedirect )
|
||||||
|
{
|
||||||
|
qDebug() << "blocked audio url from page redirect" << info.requestUrl().url();
|
||||||
|
info.block( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue