Bug 255543 - Konversation error open a bookmark
Summary: Konversation error open a bookmark
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: 1.3.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-28 22:30 UTC by francisco_t
Modified: 2010-10-29 20:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description francisco_t 2010-10-28 22:30:47 UTC
Version:           1.3.1 (using KDE 4.5.2) 
OS:                Linux

When I click in some channel in my bookmark, konvesation open a "irc" tab with this errors:
[22:29] [Info] Looking for server irc (port 0) ...
[22:29] [Error] Connection to server irc (port 0) lost: Unknown error.
[22:29] [Info] Trying to reconnect to irc (port 0) in 10 seconds.

Reproducible: Always

Steps to Reproduce:
1.- I add a channel in my bookmark.
2.- I want open the channel and click in.
3.- Konversation always open a "irc" tab with some error.



OS: Linux (x86_64) release 2.6.35-22-generic
Compiler: cc
Comment 1 Eike Hein 2010-10-29 09:15:50 UTC
Could you tell us which channel on which server you were trying to bookmark?
Comment 2 francisco_t 2010-10-29 17:11:30 UTC
Server: irc.ubuntu.com : 8001 (freenode)

Bookmark file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xbel>
<xbel folded="no" xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks" xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info" xmlns:kdepriv="http://www.kde.org/kdepriv" dbusName="konversation">
 <bookmark href="irc:/#kubuntu">
  <title>#kubuntu (Ubuntu IRC)</title>
  <info>
   <metadata owner="http://freedesktop.org">
    <bookmark:icon name="application-octet-stream"/>
   </metadata>
  </info>
  <desc/>
 </bookmark>
 <bookmark href="irc:/#kubuntu-es">
  <title>#kubuntu-es (Ubuntu IRC)</title>
  <info>
   <metadata owner="http://freedesktop.org">
    <bookmark:icon name="application-octet-stream"/>
   </metadata>
  </info>
  <desc/>
 </bookmark>
 <bookmark href="irc:/#kubuntu-devel">
  <title>#kubuntu-devel (Ubuntu IRC)</title>
  <info>
   <metadata owner="http://freedesktop.org">
    <bookmark:icon name="application-octet-stream"/>
   </metadata>
  </info>
  <desc/>
 </bookmark>
</xbel>


How I added?
From inside channel -> Bookmards -> Add bookmark

Note: I used kde 4.3 in kubuntu, now I use kde 4.5.2 with new kubuntu but with same file configuration, but I try delete the config file konversationrc and bookmarks, I set from zero, but I had the same problem.
Comment 3 Eike Hein 2010-10-29 17:27:11 UTC
Thank you, good info - will look into it.
Comment 4 Eike Hein 2010-10-29 20:19:33 UTC
commit 884b34730db945fe1fd337c0db5ed2383f3a358f
branch master
Author: Eike Hein <hein@kde.org>
Date:   Fri Oct 29 20:20:02 2010 +0200

    Bookmark URL generation improvements.
    
    Check whether QUrl accepts the network name as a hostname before
    using it, otherwise we get into trouble in the KDE bookmarking
    code. Fall back to the server hostname if we have to. Fixes book-
    marking when the network name e.g. contains a space.
    BUG:255543
    
    Also excise the leading # in standard channel names - we handle
    both cases fine, but it's implicit in the IRC url "standard".

diff --git a/src/viewer/chatwindow.cpp b/src/viewer/chatwindow.cpp
index 4133004..6637719 100644
--- a/src/viewer/chatwindow.cpp
+++ b/src/viewer/chatwindow.cpp
@@ -109,13 +109,30 @@ QString ChatWindow::getURI(bool passNetwork)
     QString server;
     QString channel;
 
+    if (getServer()->getUseSSL())
+        protocol = "ircs://";
+    else
+        protocol = "irc://";
 
     if (getType() == Channel)
-        channel = getName();
+        channel = getName().replace(QRegExp("^#"), QString());
 
     if (passNetwork)
+    {
         server = getServer()->getDisplayName();
-    else
+
+        QUrl test(protocol+server);
+
+        // QUrl (ultimately used by the bookmark system, which is the
+        // primary consumer here) doesn't like spaces in hostnames as
+        // well as other things which are possible in user-chosen net-
+        // work names, so let's fall back to the hostname if we can't
+        // get the network name by it.
+        if (!test.isValid())
+            passNetwork = false;
+    }
+
+    if (!passNetwork)
     {
         server = getServer()->getServerName();
         port = ':'+QString::number(getServer()->getPort());
@@ -124,11 +141,6 @@ QString ChatWindow::getURI(bool passNetwork)
     if (server.contains(':')) // IPv6
         server = '['+server+']';
 
-    if (getServer()->getUseSSL())
-        protocol = "ircs://";
-    else
-        protocol = "irc://";
-
     url = protocol+server+port+'/'+channel;
 
     return url;