fix: iframe should let the url passthrough if the url's baseHost matches with the iframe's baseHost

This commit is contained in:
Xiao YiFang 2022-05-17 07:55:32 +08:00
parent 7bc00750d2
commit e8c550e20a

View file

@ -11,7 +11,8 @@ WebUrlRequestInterceptor::WebUrlRequestInterceptor(QObject *p)
void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info) { void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info) {
if( Utils::isExternalLink( info.requestUrl() ) ) if( Utils::isExternalLink( info.requestUrl() ) )
{ {
if(GlobalBroadcaster::instance()-> existedInWhitelist(info.requestUrl().host())) auto hostBase = getHostBase( info.requestUrl().host() );
if( GlobalBroadcaster::instance()->existedInWhitelist( hostBase ) )
{ {
//whitelist url does not block //whitelist url does not block
return; return;
@ -20,7 +21,12 @@ void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info)
//let throuth the resources file. //let throuth the resources file.
return; return;
} }
info.block(true);
// configure should the gd block external links
// if( GlobalBroadcaster::instance()->getPreference()->disallowContentFromOtherSites )
{
info.block( true );
}
} }
if (QWebEngineUrlRequestInfo::NavigationTypeLink == info.navigationType() && info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) { if (QWebEngineUrlRequestInfo::NavigationTypeLink == info.navigationType() && info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {