Ticket #3179: fix_attach_patch.diff

File fix_attach_patch.diff, 1.1 KB (added by chrisbra, 3 years ago)
  • headers.c

    # This patch allows to specify files with spaces with the attach: header.
    # see http://dev.mutt.org/trac/ticket/3179
    old new  
    152152      BODY *body; 
    153153      BODY *parts; 
    154154      char *q; 
     155      int bs=0; 
     156      int leng=0; 
    155157 
    156158      p = cur->data + 7; 
    157159      SKIPWS (p); 
    158160      if (*p) 
    159       { 
    160         if ((q = strpbrk (p, " \t"))) 
    161         { 
    162           mutt_substrcpy (path, p, q, sizeof (path)); 
    163           SKIPWS (q); 
     161      {  
     162        q=p; 
     163        while (*p) { 
     164          if (*p == '\\'){ 
     165            bs=1; 
     166          } 
     167          if (isspace(*p)){ 
     168            if (bs){ 
     169              q--; 
     170              *q = *p; 
     171              p++;  
     172              q++; 
     173              bs = 0; 
     174              continue; 
     175            } 
     176            else 
     177              break; 
     178          } 
     179          *q = *p; 
     180          q++; 
     181          p++; 
     182          leng++; 
    164183        } 
    165         else 
    166           strfcpy (path, p, sizeof (path)); 
     184        *q='\0' 
     185        q-=leng; 
     186        strfcpy (path, q, leng+1);  
     187        SKIPWS (p); 
     188 
    167189        mutt_expand_path (path, sizeof (path)); 
    168190        if ((body = mutt_make_file_attach (path))) 
    169191        { 
    170           body->description = safe_strdup (q); 
     192          body->description = safe_strdup (p); 
    171193          for (parts = msg->content; parts->next; parts = parts->next) ; 
    172194          parts->next = body; 
    173195        }