Changeset 1822

Show
Ignore:
Timestamp:
09/19/06 17:24:29 (2 years ago)
Author:
karman
Message:

quote patch from ldrolez@debian.org

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/swish-e/src/filter.c

    r1799 r1822  
    5151static char *filterCallCmdOptParam2(char *str, char param, FileProp * fp); 
    5252static char *filterCallCmdOptStr(char *opt_mask, FileProp * fprop); 
    53  
     53static void stringQuote(char *str); 
    5454 
    5555 
     
    335335    /* if no filter cmd param given, use default */ 
    336336 
    337     opt_mask = (fi->options && *(fi->options) ) ? fi->options : "'%p' '%P'"; 
     337    opt_mask = (fi->options && *(fi->options) ) ? fi->options : "%p %P"; 
    338338    cmd_opts = filterCallCmdOptStr(opt_mask, fprop); 
    339339 
     
    385385           *co, 
    386386           *om; 
    387     int     max = MAXSTRLEN *3
     387    int     max = MAXSTRLEN *4
    388388 
    389389 
     
    396396 
    397397        /* Argh! no overflow checking. Fix $$$ - Mar 2002 - moseley */ 
    398  
     398         
    399399        switch (*om) { 
    400400 
     
    432432    case 'P':                  /* Full Doc Path/URL */ 
    433433        strcpy(str, (fprop->real_path) ? fprop->real_path : nul); 
     434        stringQuote(str); 
    434435        break; 
    435436 
    436437    case 'p':                  /* Full Path TMP/Work path */ 
    437438        strcpy(str, (fprop->work_path) ? fprop->work_path : nul); 
     439        stringQuote(str); 
    438440#if defined(_WIN32) && !defined(__CYGWIN__) 
    439441        make_windows_path( str ); 
     
    481483} 
    482484 
    483  
     485/* 
     486 * Fix for Debian: escape all non alphanum characters in paths 
     487 * --  Ludovic Drolez 
     488 */ 
     489void stringQuote(char *str) 
     490
     491    char *copy; 
     492     
     493    copy = (char *) emalloc(strlen(str)+1); 
     494    strcpy(copy, str); 
     495 
     496    for ( ;*copy; ) { 
     497        if (!isalnum(*copy) && (*copy != '/') ) { 
     498                *str++ = '\\';   
     499        } 
     500        *str++ = *copy++; 
     501    } 
     502    *str = 0; 
     503     
     504    efree(copy); 
     505