View | Details | Raw Unified | Return to bug 31490
Collapse All | Expand All

(-)modules/proxy/mod_proxy_ftp.c (-16 / +16 lines)
Lines 504-512 Link Here
504
504
505
        /* a directory/file? */
505
        /* a directory/file? */
506
        else if (ctx->buffer[0] == 'd' || ctx->buffer[0] == '-' || ctx->buffer[0] == 'l' || apr_isdigit(ctx->buffer[0])) {
506
        else if (ctx->buffer[0] == 'd' || ctx->buffer[0] == '-' || ctx->buffer[0] == 'l' || apr_isdigit(ctx->buffer[0])) {
507
            int searchidx = 0;
508
            char *searchptr = NULL;
507
            char *searchptr = NULL;
509
            int firstfile = 1;
510
            if (apr_isdigit(ctx->buffer[0])) {  /* handle DOS dir */
508
            if (apr_isdigit(ctx->buffer[0])) {  /* handle DOS dir */
511
                searchptr = strchr(ctx->buffer, '<');
509
                searchptr = strchr(ctx->buffer, '<');
512
                if (searchptr != NULL)
510
                if (searchptr != NULL)
Lines 514-535 Link Here
514
                searchptr = strchr(ctx->buffer, '>');
512
                searchptr = strchr(ctx->buffer, '>');
515
                if (searchptr != NULL)
513
                if (searchptr != NULL)
516
                    *searchptr = ']';
514
                    *searchptr = ']';
515
                filename = strrchr(ctx->buffer, ' ');
516
                *(filename++) = '\0';
517
            } else {
518
                /* Assume it is a unix format. Unless we find out using
519
                 * a SYST at the begining, we do not have a way to know for sure.*/
520
                /* Unix ls -l format:
521
                 * perm links owner group bytes month day hour:min path
522
                 */
523
                int cchars = 0;
524
                char* f = ctx->buffer;
525
                for(cchars = 0; cchars < 8; ++cchars) {
526
                    f = strchr(f, ' ');
527
                    while(*(++f) == ' ');
528
                }
529
                *(f-1) = '\0';
530
                filename = f;
517
            }
531
            }
518
532
519
            filename = strrchr(ctx->buffer, ' ');
520
            *(filename++) = '\0';
521
522
            /* handle filenames with spaces in 'em */
523
            if (!strcmp(filename, ".") || !strcmp(filename, "..") || firstfile) {
524
                firstfile = 0;
525
                searchidx = filename - ctx->buffer;
526
            }
527
            else if (searchidx != 0 && ctx->buffer[searchidx] != 0) {
528
                *(--filename) = ' ';
529
                ctx->buffer[searchidx - 1] = '\0';
530
                filename = &ctx->buffer[searchidx];
531
            }
532
533
            /* Append a slash to the HREF link for directories */
533
            /* Append a slash to the HREF link for directories */
534
            if (!strcmp(filename, ".") || !strcmp(filename, "..") || ctx->buffer[0] == 'd') {
534
            if (!strcmp(filename, ".") || !strcmp(filename, "..") || ctx->buffer[0] == 'd') {
535
                str = apr_psprintf(p, "%s <a href=\"%s/\">%s</a>\n",
535
                str = apr_psprintf(p, "%s <a href=\"%s/\">%s</a>\n",

Return to bug 31490