Fix for `hostname-whitespace'; thanks to Justin Bradford.
[u/mdw/putty] / window.c
index aa6b680..ddd7aa9 100644 (file)
--- a/window.c
+++ b/window.c
@@ -430,6 +430,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
         * Trim a colon suffix off the hostname if it's there.
         */
        cfg.host[strcspn(cfg.host, ":")] = '\0';
+
+       /*
+        * Remove any remaining whitespace from the hostname.
+        */
+       {
+           int p1 = 0, p2 = 0;
+           while (cfg.host[p2] != '\0') {
+               if (cfg.host[p2] != ' ' && cfg.host[p2] != '\t') {
+                   cfg.host[p1] = cfg.host[p2];
+                   p1++;
+               }
+               p2++;
+           }
+           cfg.host[p1] = '\0';
+       }
     }
 
     /*