Hi!

I already reported a bug about this today:
https://bugs.kde.org/show_bug.cgi?id=224636
well, i can't reproduce the first part of it (although i did get that behaviour 
everytime i tried it this afternoon... can't figure out why...) but the second 
part still persists:
in some urls, trailing spaces are converted to %20 . for example:
"http://www.google.de/ "                doesn't work (%20)
"www.google.de "                        does work
"http://www.google.de "         doesn't work (url gets changed to "http:")

i poked around in the sources and i found a solution, though there might be a 
more elegant one...

my first commit ever to a kde project, so... be kind ;)

btw: stumbled upon rekonq just today and i love it! you're doing a great job!
From f7ce64c3369b7ae8523742cabb3212158e869650 Mon Sep 17 00:00:00 2001
From: thomas gahr <[email protected]>
Date: Fri, 29 Jan 2010 02:01:11 +0100
Subject: [PATCH] fix for trailing whitespace in url

---
 src/application.cpp   |    1 -
 src/urlbar/urlbar.cpp |   51 +++++++++++++++++++++++++-----------------------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/application.cpp b/src/application.cpp
index 05004f3..88280b0 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -273,7 +273,6 @@ KIcon Application::icon(const KUrl &url)
     return icon;
 }
 
-
 void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
 {
     if (url.isEmpty())
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index be19dae..f35e4be 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -305,30 +305,33 @@ bool UrlBar::isLoading()
 void UrlBar::keyPressEvent(QKeyEvent *event)
 {
     QString currentText = m_lineEdit->text().trimmed();
-    if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
-        && !currentText.startsWith(QLatin1String("http://";), Qt::CaseInsensitive))
-    {
-        QString append;
-        if (event->modifiers() == Qt::ControlModifier)
-        {
-            append = QLatin1String(".com");
-        }
-        else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
-        {
-            append = QLatin1String(".org");
-        }
-        else if (event->modifiers() == Qt::ShiftModifier)
-        {
-            append = QLatin1String(".net");
-        }
-
-        QUrl url(QLatin1String("http://www.";) + currentText);
-        QString host = url.host();
-        if (!host.endsWith(append, Qt::CaseInsensitive))
-        {
-            host += append;
-            url.setHost(host);
-            m_lineEdit->setText(url.toString());
+    if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return){
+        if( !currentText.startsWith(QLatin1String("http://";), Qt::CaseInsensitive)){
+            QString append;
+            if (event->modifiers() == Qt::ControlModifier)
+            {
+                append = QLatin1String(".com");
+            }
+            else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
+            {
+                append = QLatin1String(".org");
+            }
+            else if (event->modifiers() == Qt::ShiftModifier)
+            {
+                append = QLatin1String(".net");
+            }
+
+            QUrl url(QLatin1String("http://www.";) + currentText);
+            QString host = url.host();
+            if (!host.endsWith(append, Qt::CaseInsensitive))
+            {
+                host += append;
+                url.setHost(host);
+                m_lineEdit->setText(url.toString());
+            }
+        }else{
+            //fill lineEdit with its stripped contents to remove trailing spaces
+            m_lineEdit->setText(currentText);
         }
     }
 
-- 
1.6.6

_______________________________________________
rekonq mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/rekonq

Reply via email to