Skip to content

Commit

Permalink
Revert f83796a as it was obsoleted by qtwebkit/qtwebkit@37a183b
Browse files Browse the repository at this point in the history
  • Loading branch information
datadiode committed Jun 23, 2023
1 parent b573a72 commit 89dd1be
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions src/webpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,36 +328,6 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url,
#endif
}

// The chromium guys have documented many examples of incompatibilities that
// different browsers have when they mime sniff.
// http://src.chromium.org/viewvc/chrome/trunk/src/net/base/mime_sniffer.cc
//
// All WebKit ports should share a common set of rules to sniff content.
// By having this here we are yet another browser that has different behavior :(
// But sadly QtWebKit does no sniffing at all so we are forced to do something.
static bool contentSniff(const QByteArray &data)
{
if (data.contains("<!doctype")
|| data.contains("<script")
|| data.contains("<html")
|| data.contains("<!--")
|| data.contains("<head")
|| data.contains("<iframe")
|| data.contains("<h1")
|| data.contains("<div")
|| data.contains("<font")
|| data.contains("<table")
|| data.contains("<a")
|| data.contains("<style")
|| data.contains("<title")
|| data.contains("<b")
|| data.contains("<body")
|| data.contains("<br")
|| data.contains("<p"))
return true;
return false;
}

void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
if (!reply)
Expand Down Expand Up @@ -397,15 +367,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
if (!notFoundFrame)
return;

if (reply->header(QNetworkRequest::ContentTypeHeader).toString().isEmpty()) {
// do evil
QByteArray data = reply->readAll();
if (contentSniff(data)) {
notFoundFrame->setHtml(QLatin1String(data), replyUrl);
return;
}
}

// Generate translated not found error page with an image
QFile notFoundErrorFile(QLatin1String(":/notfound.html"));
if (!notFoundErrorFile.open(QIODevice::ReadOnly))
Expand Down

0 comments on commit 89dd1be

Please sign in to comment.