diff --git a/src/iframeschemehandler.cc b/src/iframeschemehandler.cc index 73b69f9e..cc38c7ce 100644 --- a/src/iframeschemehandler.cc +++ b/src/iframeschemehandler.cc @@ -61,10 +61,15 @@ void IframeSchemeHandler::requestStarted( QWebEngineUrlRequestJob * requestJob ) QString root = reply->url().scheme() + "://" + reply->url().host(); QString base = root + reply->url().path(); - QRegularExpression baseTag( R"()", + QRegularExpression baseTag( R"EOF()EOF", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption ); + + if ( const auto match = baseTag.match( articleString ); match.hasMatch() ) { + base = reply->url().resolved( match.captured( 1 ) ).url(); + } + QString baseTagHtml = QString( R"()" ).arg( base ); QString depressionFocus = @@ -72,14 +77,14 @@ void IframeSchemeHandler::requestStarted( QWebEngineUrlRequestJob * requestJob ) )"; - // remove existed base tag articleString.remove( baseTag ); + articleString.replace( "window.location", "window.location;_window_location" ); QRegularExpression headTag( R"()", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption ); - auto match = headTag.match( articleString, 0 ); + auto match = headTag.match( articleString ); if ( match.hasMatch() ) { articleString.insert( match.capturedEnd(), baseTagHtml ); articleString.insert( match.capturedEnd(), depressionFocus ); diff --git a/src/weburlrequestinterceptor.cc b/src/weburlrequestinterceptor.cc index be156bc8..993b220a 100644 --- a/src/weburlrequestinterceptor.cc +++ b/src/weburlrequestinterceptor.cc @@ -9,8 +9,7 @@ WebUrlRequestInterceptor::WebUrlRequestInterceptor( QObject * p ): } void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo & info ) { - - info.setHttpHeader( "origin", "*" ); + info.setHttpHeader( "origin", info.requestUrl().url().toUtf8() ); info.setHttpHeader( "referer", info.requestUrl().url().toUtf8() ); if ( GlobalBroadcaster::instance()->getPreference()->disallowContentFromOtherSites && Utils::isExternalLink( info.requestUrl() ) ) {