Bug 71177 - Konsole ssh://user@host bookmarks don't allow a port to be specified (ssh://user@host:port)
Summary: Konsole ssh://user@host bookmarks don't allow a port to be specified (ssh://u...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-24 13:55 UTC by Dave Johnson
Modified: 2004-01-09 17:35 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 Dave Johnson 2003-12-24 13:55:46 UTC
Version:            (using KDE KDE 3.1.94)
Installed from:    Unlisted Binary Package

Konsole ssh://user@host bookmarks should allow a port to be specified (ssh://user@host:port)
Comment 1 John Shriver 2004-01-07 15:42:55 UTC
I can report that this bug is real, and it's a pain for me.  We have terminal servers milking the console ports of our servers, with each serial port served by  a telnet server on a different high numbered port.

The bookmarks I've created are of the form telnet://terminal-server:2043 .  The URL is not properly cracked into arguments into telnet.  If I try and put a space in instead of the colon, it gets translated into a %20 escape sequence.

The ktelnetservice code cracks these URL's correctly.

Here's the output on a konsole after selecting a bookmark "telnet://jshriver@terminal-server:2043":

$ telnet -l jshriver terminal-server:2043
telnet: could not resolve terminal-server:2043/telnet: Name or service not known

Here's the output on a konsole after selecting a bookmark "telnet://jshriver@terminal-server 2044":

$ telnet -l jshriver terminal-server%202044
telnet: could not resolve terminal-server%202044/telnet: Name or service not known

The presence of absence of username@ in the URL does not affect the bug.  It's correctly parsing that @ and making the -l argument, but it's not doing the same with :'s for port.  (No idea what it does with passwords.)

KDE 3.1.1a, Konsole 1.2.1, on a Debian Linux system.  Not sure if the IT folks here built from source, or downloaded the Debian "packages".
Comment 2 Waldo Bastian 2004-01-07 18:38:25 UTC
telnet works just fine in KDE 3.2
Comment 3 Waldo Bastian 2004-01-07 18:41:03 UTC
Correction: telnet urls work just fine with Alt-F2 but not in konsole.
Comment 4 Waldo Bastian 2004-01-09 17:35:56 UTC
Subject: kdebase/konsole/konsole

CVS commit by waba: 

Handle port in bookmarked telnet/ssh urls.
CCMAIL: 71177-done@bugs.kde.org


  M +19 -20    konsole.cpp   1.441


--- kdebase/konsole/konsole/konsole.cpp  #1.440:1.441
@@ -2158,5 +2158,4 @@ void Konsole::enterURL(const QString& UR
 {
   QString path, login, host, newtext;
-  int i;
 
   if (URL.startsWith("file:")) {
@@ -2167,26 +2166,19 @@ void Konsole::enterURL(const QString& UR
   }
   else if (URL.contains("://", true)) {
-    i = URL.find("://", 0);
-    newtext = URL.left(i);
-    path = URL.mid(i + 3);
-    /*
-     * Is it protocol://user@host, or protocol://host ?
-     */
-    if (path.contains("@", true)) {
-      i = path.find("@", 0);
-      login = path.left(i);
-      host = path.mid(i + 1);
-      if (!login.isEmpty()) {
-        newtext = newtext + " -l " + login;
-      }
-    } else {
-      host = path;
-    }
+    KURL u(URL);
+    newtext = u.protocol();
+    bool isSSH = (newtext == "ssh");
+    if (u.port() && isSSH)
+       newtext += " -p " + QString().setNum(u.port());
+    if (u.hasUser())
+       newtext += " -l " + u.user();
 
     /*
      * If we have a host, connect.
      */
-    if (!host.isEmpty()) {
-      newtext = newtext + " " + host;
+    if (u.hasHost()) {
+      newtext = newtext + " " + u.host();
+      if (u.port() && !isSSH)
+         newtext += QString(" %1").arg(u.port());
       se->setUserTitle(31,"");           // we don't know remote cwd
       te->emitText(newtext + "\r");
@@ -2648,6 +2640,11 @@ void Konsole::newSession(const QString& 
    else if ((!url.protocol().isEmpty()) && (url.hasHost())) {
      protocol = url.protocol();
+     bool isSSH = (protocol == "ssh");
      args.append( protocol.latin1() ); /* argv[0] == command to run. */
      host = url.host();
+     if (url.port() && isSSH) {
+       args.append("-p");
+       args.append(QCString().setNum(url.port()));
+     }
      if (url.hasUser()) {
        login = url.user();
@@ -2656,4 +2653,6 @@ void Konsole::newSession(const QString& 
      }
      args.append(host.latin1());
+     if (url.port() && !isSSH)
+       args.append(QCString().setNum(url.port()));
      newSession( NULL, protocol.latin1() /* protocol */, args /* arguments */,
                  QString::null /*term*/, QString::null /*icon*/,