diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-08-01 20:17:42 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-08-01 20:17:42 +0200 |
commit | fc09a97540b71be2bb39d77bb0e64d1f8b3cf34c (patch) | |
tree | cabe66145e811eb6ff168d4844f8773cf3d0ef85 | |
parent | Fixing a bit enum OpenType names.. (diff) | |
download | rekonq-fc09a97540b71be2bb39d77bb0e64d1f8b3cf34c.tar.xz |
loadUrl function fix (hopefully, last!)
-rw-r--r-- | src/application.cpp | 38 |
1 files 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 <KPassivePopup> #include <KToolInvocation> #include <KUriFilter> +#include <KMessageBox> +#include <KProtocolInfo> // Qt Includes #include <QRegExp> @@ -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; |