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:56:42 GMT
martin      02/01/29 09:56:42

  Modified:    modules/proxy proxy_ftp.c
  Log:
  If the ftp proxy could not guess the output format of the ftp server's
  directory listing, it makes another attempt: it tries a format similar to
  the output of "ls -s1" (optional whitespace followed by size, followed by
  whitespace, followed by filename, where filename may contain no more whitespace).
  This format works at least with one FTP server for which previously only
  the (non-clickable) output was displayed.
  
  Revision  Changes    Path
  1.92      +15 -0     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.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- proxy_ftp.c	29 Jan 2002 17:07:26 -0000	1.91
  +++ proxy_ftp.c	29 Jan 2002 17:56:42 -0000	1.92
  @@ -273,6 +273,8 @@
       apr_bucket *e;
       apr_bucket_brigade *out = apr_brigade_create(p);
       apr_status_t rv;
  +    regex_t *re = NULL; /* @@@ put this in the context */
  +    regmatch_t re_result[3];
   
       register int n;
       char *dir, *path, *reldir, *site, *str;
  @@ -281,6 +283,7 @@
       const char *readme = apr_table_get(r->notes, "Directory-README");
   
       proxy_dir_ctx_t *ctx = f->ctx;
  +
       if (!ctx) {
           f->ctx = ctx = apr_pcalloc(p, sizeof(*ctx));
           ctx->in = apr_brigade_create(p);
  @@ -288,6 +291,9 @@
           ctx->state = HEADER;
       }
   
  +    /* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
  +    re = ap_pregcomp(p, "^ *([0-9]+) +([^ ]+)$", REG_EXTENDED);
  +
       /* combine the stored and the new */
       APR_BRIGADE_CONCAT(ctx->in, in);
   
  @@ -477,6 +483,15 @@
                                      ap_escape_uri(p, filename),
                                      ap_escape_html(p, filename));
               }
  +        }
  +        /* Try a fallback for listings in the format of "ls -s1" */
  +        else if (0 == ap_regexec(re, ctx->buffer, 3, re_result, 0)) {
  +
  +            char *filename = apr_pstrndup(p, &ctx->buffer[re_result[2].rm_so], re_result[2].rm_eo
- re_result[2].rm_so);
  +
  +            str = ap_pstrcat(p, ap_escape_html(p, apr_pstrndup(p, &ctx->buffer[0],
re_result[2].rm_so)),
  +                             "<a href=\"", ap_escape_uri(p, filename), "\">",
  +                             ap_escape_html(p, filename), "</a>\n", NULL);
           }
           else {
               strcat(ctx->buffer, "\n"); /* re-append the newline */
  
  
  

Mime
View raw message