[Konsole-devel] [Bug 71177] Konsole ssh://user at host bookmarks don't allow a port to be specified (ssh://user at host:port)

Waldo Bastian bastian at kde.org
Fri Jan 9 16:35:57 UTC 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=71177      
bastian at kde.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From bastian at kde.org  2004-01-09 17:35 -------
Subject: kdebase/konsole/konsole

CVS commit by waba: 

Handle port in bookmarked telnet/ssh urls.
CCMAIL: 71177-done at 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*/,



More information about the konsole-devel mailing list