summaryrefslogtreecommitdiff
path: root/src/application.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/application.cpp')
-rw-r--r--src/application.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 565c6ab3..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,31 +259,41 @@ 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);
return;
}
-
+
KUrl loadingUrl(url);
- if (loadingUrl.isRelative())
+ // 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))
{
- QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash);
- if(loadingUrl.path().contains('.'))
- {
- loadingUrl.setUrl("//" + fn);
- loadingUrl.setScheme("http");
- }
- else
- {
- loadingUrl.setUrl(fn);
- loadingUrl.setScheme("gg");
- }
+ loadingUrl = data.uri().url();
+ }
+
+ if (loadingUrl.isRelative() && !loadingUrl.path().contains("."))
+ {
+ QString urlString = QString("http://www.google.com/search?q=%1").arg(loadingUrl.path());
+ loadingUrl = KUrl(urlString);
+ }
+
+ if ( !KProtocolInfo::isKnownProtocol( loadingUrl ) )
+ {
+ KMessageBox::error(0, i18n("Protocol not supported\n%1", url.protocol()));
+ return;
}
-
- // this should let rekonq to support the beautiful KDE web browsing shortcuts
- loadingUrl = KUriFilter::self()->filteredUri(loadingUrl);
WebView *webView;
@@ -310,7 +322,6 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
}
}
-
void Application::loadUrl(const QString& urlString, const Rekonq::OpenType& type)
{
return loadUrl( guessUrlFromString(urlString), type );