chuck       97/04/13 20:43:34

  Modified:    src/modules/proxy  proxy_ftp.c
  Log:
  Encode spaces for displayed filenames in directories.
  
  Revision  Changes    Path
  1.20      +26 -2     apache/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -C3 -r1.19 -r1.20
  *** proxy_ftp.c       1997/04/13 15:20:30     1.19
  --- proxy_ftp.c       1997/04/14 03:43:33     1.20
  ***************
  *** 149,155 ****
        }
        else
        {
  !         p = proxy_canonenc(pool, r->args, strlen(r->args), enc_path, 1);
            if (p == NULL) return BAD_REQUEST;
            path = pstrcat(pool, path, "?", p, NULL);
        }
  --- 149,155 ----
        }
        else
        {
  !         p = proxy_canonenc(pool, r->args, strlen(r->args), enc_fpath, 1);
            if (p == NULL) return BAD_REQUEST;
            path = pstrcat(pool, path, "?", p, NULL);
        }
  ***************
  *** 213,218 ****
  --- 213,239 ----
        return status;
    }
    
  + static char *
  + encode_space(request_rec *r, char *path)
  + {
  +     pool *pool=r->pool;
  +     char *newpath;
  +     int i, j, len;
  + 
  +     len = strlen(path);
  +     newpath = palloc(pool, 3 * len + 1);
  +     for (i=0, j=0; i < len; i++, j++) {
  +     if (path[i] != ' ')
  +         newpath[j] = path[i];
  +     else {
  +         proxy_c2hex(' ', &newpath[j]);
  +         j += 2;
  +     }
  +     }
  +     newpath[j] = '\0';
  +     return newpath;
  + }
  + 
    static long int
    send_dir(BUFF *f, request_rec *r, BUFF *f2, struct cache_req *c, char *url)
    {
  ***************
  *** 220,225 ****
  --- 241,247 ----
        char buf2[IOBUFSIZE];
        char *filename;
        char *tempurl;
  +     char *newurlptr;
        int searchidx = 0;
        char *searchptr = NULL;
        int firstfile = 1;
  ***************
  *** 235,240 ****
  --- 257,263 ----
        tempurl += n - 5;       /* leave room for ftp:// */
        }
    
  +     n = decodeenc(tempurl);
        ap_snprintf(buf, sizeof(buf), 
"<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>Directory %s</H1><HR><PRE>", 
tempurl, tempurl);
        bwrite(con->client, buf, strlen(buf));
        if (f2 != NULL) bwrite(f2, buf, strlen(buf));
  ***************
  *** 326,332 ****
                else 
                {
                    ap_snprintf(urlptr, sizeof(urlptr), 
"%s%s%s",url,(url[strlen(url)-1]=='/' ? "" : "/"), filename);
  !                 ap_snprintf(buf2, sizeof(buf2), "%s <A 
HREF=\"%s\">%s</A>\015\012", buf, urlptr, filename);
                }
                strncpy(buf, buf2, sizeof(buf));
            buf[sizeof(buf)-1] = '\0';
  --- 349,356 ----
                else 
                {
                    ap_snprintf(urlptr, sizeof(urlptr), 
"%s%s%s",url,(url[strlen(url)-1]=='/' ? "" : "/"), filename);
  !             newurlptr = encode_space(r, urlptr);
  !                 ap_snprintf(buf2, sizeof(buf2), "%s <A 
HREF=\"%s\">%s</A>\015\012", buf, newurlptr, filename);
                }
                strncpy(buf, buf2, sizeof(buf));
            buf[sizeof(buf)-1] = '\0';
  
  
  

Reply via email to