diff --git a/iframeschemehandler.cpp b/iframeschemehandler.cpp index b050cd14..52d20f04 100644 --- a/iframeschemehandler.cpp +++ b/iframeschemehandler.cpp @@ -55,13 +55,19 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) articleString.remove( baseTag ) ; QRegularExpression headTag( "", - QRegularExpression::CaseInsensitiveOption - | QRegularExpression::DotMatchesEverythingOption ); + QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption ); auto match = headTag.match( articleString, 0 ); if( match.hasMatch() ) { articleString.insert( match.capturedEnd(), baseTagHtml ); } + else + { + // the html contain no head element + // just insert at the beginning of the html ,and leave it at the mercy of browser(chrome webengine) + articleString.insert( 0, baseTagHtml ); + } buffer->setData(codec->fromUnicode(articleString));