That will add an extra newline in the proxy case where it does:

        fprintf(ttyout, "Requesting %s", origline);

        ...

        fprintf(ttyout, " (via %s)\n", proxyurl);

There is actually a newline printed for the non-proxy case but it
happens too late.

We either need to avoid printing a newline in the "Requesting"
message for the proxyurl case or just avoid splitting the message
in the first place, which is what I've done below.

 - todd

Index: usr.bin/ftp/fetch.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.150
diff -u -p -u -r1.150 fetch.c
--- usr.bin/ftp/fetch.c 8 Dec 2016 19:31:17 -0000       1.150
+++ usr.bin/ftp/fetch.c 8 Dec 2016 19:43:25 -0000
@@ -624,9 +624,6 @@ noslash:
        fin = fdopen(s, "r+");
 #endif /* !SMALL */
 
-       if (verbose)
-               fprintf(ttyout, "Requesting %s", origline);
-
        /*
         * Construct and send the request. Proxy requests don't want leading /.
         */
@@ -636,8 +633,10 @@ noslash:
 
        epath = url_encode(path);
        if (proxyurl) {
-               if (verbose)
-                       fprintf(ttyout, " (via %s)\n", proxyurl);
+               if (verbose) {
+                       fprintf(ttyout, "Requesting %s (via %s)\n",
+                           origline, proxyurl);
+               }
                /*
                 * Host: directive must use the destination host address for
                 * the original URI (path).
@@ -653,6 +652,8 @@ noslash:
                            "Host: %s\r\n%s%s\r\n\r\n",
                            epath, proxyhost, buf ? buf : "", httpuseragent);
        } else {
+               if (verbose)
+                       fprintf(ttyout, "Requesting %s\n", origline);
 #ifndef SMALL
                if (resume) {
                        struct stat stbuf;
@@ -712,8 +713,6 @@ noslash:
 #endif /* !SMALL */
                ftp_printf(fin, tls, "\r\n%s%s\r\n\r\n",
                    buf ? buf : "", httpuseragent);
-               if (verbose)
-                       fprintf(ttyout, "\n");
        }
        free(epath);
 

Reply via email to