From ab368f647fc92a61bc1a5d0375eb895e4a3146d5 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 13 Dec 2014 03:37:41 +0330 Subject: [PATCH] Assume "about:blank" as an empty URL. - Closes #1539 --- src/lib/navigation/locationbar.cpp | 2 +- src/lib/webkit/webview.cpp | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 5213081aa..44b502786 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -336,7 +336,7 @@ void LocationBar::showUrl(const QUrl &url) } // Set converted url as text - setText(convertUrlToText(url)); + setText(stringUrl); // Move cursor to the start home(false); diff --git a/src/lib/webkit/webview.cpp b/src/lib/webkit/webview.cpp index 5bbf6b322..bff7dde10 100644 --- a/src/lib/webkit/webview.cpp +++ b/src/lib/webkit/webview.cpp @@ -129,18 +129,30 @@ bool WebView::isTitleEmpty() const return QWebView::title().isEmpty(); } +static QString convertUrlToText(const QUrl &url) +{ + // It was most probably entered by user, so don't urlencode it + if (url.scheme().isEmpty()) { + return url.toString(); + } + + QString stringUrl = QzTools::urlEncodeQueryString(url); + + if (stringUrl == QLatin1String("about:blank")) { + stringUrl.clear(); + } + + return stringUrl; +} + QUrl WebView::url() const { QUrl returnUrl = page()->url(); - if (returnUrl.isEmpty()) { + if (convertUrlToText(returnUrl).isEmpty()) { returnUrl = m_aboutToLoadUrl; } - if (returnUrl.toString() == QLatin1String("about:blank")) { - returnUrl = QUrl(); - } - return returnUrl; } @@ -404,7 +416,8 @@ void WebView::editDelete() void WebView::reload() { m_isReloading = true; - if (QWebView::url().isEmpty() && !m_aboutToLoadUrl.isEmpty()) { + + if (convertUrlToText(QWebView::url()).isEmpty() && !m_aboutToLoadUrl.isEmpty()) { load(m_aboutToLoadUrl); return; }