httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject cvs commit: httpd-2.0/modules/proxy proxy_ftp.c
Date Tue, 29 Jan 2002 17:07:26 GMT
martin      02/01/29 09:07:26

  Modified:    modules/proxy proxy_ftp.c
  Log:
  Fix handling of \r\n at the end of FTP directory listings (\r characters
  were left in the output and would create additional line breaks in most
  browsers)
  
  Revision  Changes    Path
  1.91      +12 -5     httpd-2.0/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- proxy_ftp.c	29 Jan 2002 16:55:07 -0000	1.90
  +++ proxy_ftp.c	29 Jan 2002 17:07:26 -0000	1.91
  @@ -393,8 +393,9 @@
                   len = max;
               }
   /* strncat works here, but apr_cpystrn does not - the last char gets chopped, dunno why
*/
  -/*          apr_cpystrn(ctx->buffer+strlen(ctx->buffer), response, len);*/
  -            strncat(ctx->buffer, response, len);
  +/*            strncat(ctx->buffer, response, len);*/
  +            /* +1 to leave spave for the trailing nil char */
  +            apr_cpystrn(ctx->buffer+strlen(ctx->buffer), response, len+1);
               APR_BUCKET_REMOVE(e);
               apr_bucket_destroy(e);
           }
  @@ -410,6 +411,14 @@
               return APR_SUCCESS;
           }
   
  +        {
  +            size_t n = strlen(ctx->buffer);
  +            if (ctx->buffer[n-1] == '\n')  /* strip trailing '\n' */
  +                ctx->buffer[--n] = '\0';
  +            if (ctx->buffer[n-1] == '\r')  /* strip trailing '\r' if present */
  +                ctx->buffer[--n] = '\0';
  +        }
  +
           /* a symlink? */
           if (ctx->buffer[0] == 'l' && (filename = strstr(ctx->buffer, " ->
")) != NULL) {
               char *link_ptr = filename;
  @@ -420,8 +429,6 @@
               if (filename > ctx->buffer)
                   *(filename++) = '\0';
               *(link_ptr++) = '\0';
  -            if ((n = strlen(link_ptr)) > 1 && link_ptr[n - 1] == '\n')
  -                link_ptr[n - 1] = '\0';
               str = apr_psprintf(p, "%s <a href=\"%s\">%s %s</a>\n",
                                  ap_escape_html(p, ctx->buffer),
                                  ap_escape_uri(p, filename),
  @@ -445,7 +452,6 @@
   
               filename = strrchr(ctx->buffer, ' ');
               *(filename++) = 0;
  -            filename[strlen(filename) - 1] = 0;
   
               /* handle filenames with spaces in 'em */
               if (!strcmp(filename, ".") || !strcmp(filename, "..") || firstfile) {
  @@ -473,6 +479,7 @@
               }
           }
           else {
  +            strcat(ctx->buffer, "\n"); /* re-append the newline */
               str = ap_escape_html(p, ctx->buffer);
           }
   
  
  
  

Mime
View raw message