From fc09a97540b71be2bb39d77bb0e64d1f8b3cf34c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 1 Aug 2009 20:17:42 +0200 Subject: loadUrl function fix (hopefully, last!) --- src/application.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index a9797f3e..6cfdf03c 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include // Qt Includes #include @@ -257,6 +259,12 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) if (url.isEmpty()) return; + if ( !url.isValid() ) + { + KMessageBox::error(0, i18n("Malformed URL\n%1", url.url())); + return; + } + if (url.scheme() == QLatin1String("mailto")) { KToolInvocation::invokeMailer(url); @@ -264,21 +272,27 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) } KUrl loadingUrl(url); - if (loadingUrl.isRelative() && loadingUrl.path().contains(".")) + + // this should let rekonq filtering URI info and supporting + // the beautiful KDE web browsing shortcuts + KUriFilterData data(loadingUrl.pathOrUrl()); + data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" + // are considered as executables + if (KUriFilter::self()->filterUri(data)) + { + loadingUrl = data.uri().url(); + } + + if (loadingUrl.isRelative() && !loadingUrl.path().contains(".")) { - QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); - loadingUrl.setUrl("//" + fn); - loadingUrl.setScheme("http"); + QString urlString = QString("http://www.google.com/search?q=%1").arg(loadingUrl.path()); + loadingUrl = KUrl(urlString); } - else if(loadingUrl.scheme()!="http") + + if ( !KProtocolInfo::isKnownProtocol( loadingUrl ) ) { - // this should let rekonq to support the beautiful KDE web browsing shortcuts - KUriFilterData data(loadingUrl.pathOrUrl()); - data.setCheckForExecutables (false); //if true, querries like "rekonq" or "dolphin" are considered as executables - if (KUriFilter::self()->filterUri(data)) - { - loadingUrl = data.uri().url(); - } + KMessageBox::error(0, i18n("Protocol not supported\n%1", url.protocol())); + return; } WebView *webView; -- cgit v1.2.1