From 165b33a94e53e04972f18657029dbe27caea2c06 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 16 Mar 2010 00:20:32 +0000 Subject: [PATCH] Fixed Web UI compatibility with Safari --- src/httpconnection.cpp | 8 +++ src/httpserver.cpp | 2 +- src/src.pro | 2 +- src/webui/scripts/client.js | 124 +++++++++++++++++++++++++++++++++--- 4 files changed, 124 insertions(+), 12 deletions(-) diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index af544119a..ac267d18b 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -140,6 +140,14 @@ void HttpConnection::respond() { return; } QString auth = parser.value("Authorization"); + if(auth.isEmpty()) { + // Return unauthorized header + qDebug("Auth is Empty..."); + generator.setStatusLine(401, "Unauthorized"); + generator.setValue("WWW-Authenticate", "Digest realm=\""+QString(QBT_REALM)+"\", nonce=\""+parent->generateNonce()+"\", opaque=\""+parent->generateNonce()+"\", stale=\"false\", algorithm=\"MD5\", qop=\"auth\""); + write(); + return; + } qDebug("Auth: %s", qPrintable(auth.split(" ").first())); if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth.toLocal8Bit(), parser.method())) { // Update failed attempt counter diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 292827194..8d916dd00 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -259,7 +259,7 @@ bool HttpServer::isAuthorized(QByteArray auth, QString method) const { md5_ha.addData(password_ha1+":"+prop_nonce+":"+ha2); response = md5_ha.result().toHex(); } - qDebug("AUTH: comparing reponses"); + qDebug("AUTH: comparing reponses: (%d)", static_cast(prop_response == response)); return prop_response == response; } diff --git a/src/src.pro b/src/src.pro index fa98c5ec4..4281e61fb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -3,7 +3,7 @@ LANG_PATH = lang ICONS_PATH = Icons # Set the following variable to 1 to enable debug -DEBUG_MODE = 0 +DEBUG_MODE = 1 # Global TEMPLATE = app diff --git a/src/webui/scripts/client.js b/src/webui/scripts/client.js index 7ad7ca472..b7c35eec5 100644 --- a/src/webui/scripts/client.js +++ b/src/webui/scripts/client.js @@ -22,6 +22,116 @@ * THE SOFTWARE. */ +// Debug +//alert(navigator.userAgent); + +// From http://www.quirksmode.org/js/detect.html +var BrowserDetect = { + init: function () { + this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; + //this.version = this.searchVersion(navigator.userAgent) + // || this.searchVersion(navigator.appVersion) + // || "an unknown version"; + //this.OS = this.searchString(this.dataOS) || "an unknown OS"; + }, + searchString: function (data) { + for (var i=0;i