Changeset 5443:8b783c916893
- Timestamp:
- 2008-07-02 02:19:14 (3 months ago)
- Author:
- Rocco Rutte <pdmef@…>
- Branch:
- HEAD
- Message:
-
Use realpath() in mutt_pretty_mailbox() for paths that may need it.
This requires to add the buffer size as parameter since the result may
be longer than the original but still fit in the buffer. Closes #2948.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5441
|
r5443
|
|
| | 1 | 2008-07-02 10:06 +0200 Rocco Rutte <pdmef@gmx.net> (cc2334fdf126) |
| | 2 | |
| | 3 | * hash.c: Use casts to avoid triggering integer overflow detection in |
| | 4 | hash function |
| | 5 | |
| | 6 | 2008-07-01 20:06 -0700 Vincent Lefevre <vincent@vinc17.org> (fb0df4ae0836) |
| | 7 | |
| | 8 | * ChangeLog, curs_lib.c: Clamp timeval math to unsigned int to match |
| | 9 | progress timestamps. This is fine since only relative differences |
| | 10 | matter. Closes #3018. |
| | 11 | |
| 1 | 12 | 2008-07-01 18:29 -0700 Brendan Cully <brendan@kublai.com> (f9af0501d2dd) |
| 2 | 13 | |
-
|
r5209
|
r5443
|
|
| 463 | 463 | |
| 464 | 464 | strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); |
| 465 | | mutt_pretty_mailbox (buffer); |
| | 465 | mutt_pretty_mailbox (buffer, sizeof (buffer)); |
| 466 | 466 | |
| 467 | 467 | add_folder (menu, state, buffer, &s, tmp->new); |
| … |
… |
|
| 509 | 509 | { |
| 510 | 510 | strfcpy (path, LastDir, sizeof (path)); |
| 511 | | mutt_pretty_mailbox (path); |
| | 511 | mutt_pretty_mailbox (path, sizeof (path)); |
| 512 | 512 | #ifdef USE_IMAP |
| 513 | 513 | if (state->imap_browse && option (OPTIMAPLSUB)) |
-
|
r5398
|
r5443
|
|
| 430 | 430 | |
| 431 | 431 | strfcpy (path, tmp->path, sizeof (path)); |
| 432 | | mutt_pretty_mailbox (path); |
| | 432 | mutt_pretty_mailbox (path, sizeof (path)); |
| 433 | 433 | |
| 434 | 434 | if (!first && pos + strlen (path) >= COLS - 7) |
| … |
… |
|
| 503 | 503 | } |
| 504 | 504 | strfcpy (s, tmp->path, slen); |
| 505 | | mutt_pretty_mailbox (s); |
| | 505 | mutt_pretty_mailbox (s, slen); |
| 506 | 506 | break; |
| 507 | 507 | |
| … |
… |
|
| 529 | 529 | } |
| 530 | 530 | strfcpy (s, tmp->path, slen); |
| 531 | | mutt_pretty_mailbox (s); |
| | 531 | mutt_pretty_mailbox (s, slen); |
| 532 | 532 | break; |
| 533 | 533 | } |
-
|
r5422
|
r5443
|
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | | mutt_pretty_mailbox (buf); |
| | 761 | mutt_pretty_mailbox (buf, sizeof (buf)); |
| 762 | 762 | if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1) |
| 763 | 763 | return (-1); |
-
|
r5358
|
r5443
|
|
| 218 | 218 | if(stat(idx[i]->content->filename, &st) != 0) |
| 219 | 219 | { |
| 220 | | mutt_pretty_mailbox(pretty); |
| | 220 | mutt_pretty_mailbox(pretty, sizeof (pretty)); |
| 221 | 221 | mutt_error(_("%s [#%d] no longer exists!"), |
| 222 | 222 | pretty, i+1); |
| … |
… |
|
| 226 | 226 | if(idx[i]->content->stamp < st.st_mtime) |
| 227 | 227 | { |
| 228 | | mutt_pretty_mailbox(pretty); |
| | 228 | mutt_pretty_mailbox(pretty, sizeof (pretty)); |
| 229 | 229 | snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"), |
| 230 | 230 | pretty, i+1); |
| … |
… |
|
| 569 | 569 | if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) |
| 570 | 570 | { |
| 571 | | strfcpy (fcc, buf, _POSIX_PATH_MAX); |
| 572 | | mutt_pretty_mailbox (fcc); |
| | 571 | strfcpy (fcc, buf, fcclen); |
| | 572 | mutt_pretty_mailbox (fcc, fcclen); |
| 573 | 573 | move (HDR_FCC, HDR_XOFFSET); |
| 574 | 574 | mutt_paddstr (W, fcc); |
| … |
… |
|
| 718 | 718 | { |
| 719 | 719 | strfcpy (fname, NONULL (Context->path), sizeof (fname)); |
| 720 | | mutt_pretty_mailbox (fname); |
| | 720 | mutt_pretty_mailbox (fname, sizeof (fname)); |
| 721 | 721 | } |
| 722 | 722 | |
| … |
… |
|
| 1006 | 1006 | CHECK_COUNT; |
| 1007 | 1007 | strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); |
| 1008 | | mutt_pretty_mailbox (fname); |
| | 1008 | mutt_pretty_mailbox (fname, sizeof (fname)); |
| 1009 | 1009 | if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE) |
| 1010 | 1010 | == 0 && fname[0]) |
| … |
… |
|
| 1195 | 1195 | { |
| 1196 | 1196 | strfcpy (fname, NONULL (Context->path), sizeof (fname)); |
| 1197 | | mutt_pretty_mailbox (fname); |
| | 1197 | mutt_pretty_mailbox (fname, sizeof (fname)); |
| 1198 | 1198 | } |
| 1199 | 1199 | if (idxlen) |
-
|
r5372
|
r5443
|
|
| 1072 | 1072 | { |
| 1073 | 1073 | strfcpy (buf, Context->path, sizeof (buf)); |
| 1074 | | mutt_pretty_mailbox (buf); |
| | 1074 | mutt_pretty_mailbox (buf, sizeof (buf)); |
| 1075 | 1075 | mutt_buffy (buf, sizeof (buf)); |
| 1076 | 1076 | if (!buf[0]) |
-
|
r5331
|
r5443
|
|
| 573 | 573 | if (*buf) |
| 574 | 574 | { |
| 575 | | mutt_pretty_mailbox (buf); |
| | 575 | mutt_pretty_mailbox (buf, buflen); |
| 576 | 576 | if (!pass) |
| 577 | 577 | mutt_history_add (hclass, buf, 1); |
-
|
r4616
|
r5443
|
|
| 144 | 144 | { |
| 145 | 145 | strfcpy (fcc, p, fcclen); |
| 146 | | mutt_pretty_mailbox (fcc); |
| | 146 | mutt_pretty_mailbox (fcc, fcclen); |
| 147 | 147 | } |
| 148 | 148 | keep = 0; |
| … |
… |
|
| 174 | 174 | else |
| 175 | 175 | { |
| 176 | | mutt_pretty_mailbox (path); |
| | 176 | mutt_pretty_mailbox (path, sizeof (path)); |
| 177 | 177 | mutt_error (_("%s: unable to attach file"), path); |
| 178 | 178 | } |
-
|
r5099
|
r5443
|
|
| 427 | 427 | strfcpy (path, NONULL (Outbox), pathlen); |
| 428 | 428 | } |
| 429 | | mutt_pretty_mailbox (path); |
| | 429 | mutt_pretty_mailbox (path, pathlen); |
| 430 | 430 | } |
| 431 | 431 | |
-
|
r5371
|
r5443
|
|
| 1991 | 1991 | /* reformat output */ |
| 1992 | 1992 | imap_qualify_path (dest, dlen, &mx, completion); |
| 1993 | | mutt_pretty_mailbox (dest); |
| | 1993 | mutt_pretty_mailbox (dest, dlen); |
| 1994 | 1994 | |
| 1995 | 1995 | FREE (&mx.mbox); |
-
|
r5416
|
r5443
|
|
| 1857 | 1857 | _tmp[0] = '\0'; |
| 1858 | 1858 | strfcpy (_tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof (_tmp)); |
| 1859 | | mutt_pretty_mailbox (_tmp); |
| | 1859 | mutt_pretty_mailbox (_tmp, sizeof (_tmp)); |
| 1860 | 1860 | val = _tmp; |
| 1861 | 1861 | } |
| … |
… |
|
| 2619 | 2619 | strfcpy (tmp, NONULL (*((char **) MuttVars[idx].data)), sizeof (tmp)); |
| 2620 | 2620 | if (DTYPE (MuttVars[idx].type) == DT_PATH) |
| 2621 | | mutt_pretty_mailbox (tmp); |
| | 2621 | mutt_pretty_mailbox (tmp, sizeof (tmp)); |
| 2622 | 2622 | } |
| 2623 | 2623 | else if (DTYPE (MuttVars[idx].type) == DT_ADDR) |
-
|
r5422
|
r5443
|
|
| 957 | 957 | mutt_unblock_signals (); |
| 958 | 958 | mx_fastclose_mailbox (ctx); |
| 959 | | mutt_pretty_mailbox (savefile); |
| | 959 | mutt_pretty_mailbox (savefile, sizeof (savefile)); |
| 960 | 960 | mutt_error (_("Write failed! Saved partial mailbox to %s"), savefile); |
| 961 | 961 | mutt_sleep (5); |
-
|
r5365
|
r5443
|
|
| 754 | 754 | |
| 755 | 755 | /* collapse the pathname using ~ or = when possible */ |
| 756 | | void mutt_pretty_mailbox (char *s) |
| | 756 | void mutt_pretty_mailbox (char *s, size_t buflen) |
| 757 | 757 | { |
| 758 | 758 | char *p = s, *q = s; |
| 759 | 759 | size_t len; |
| 760 | 760 | url_scheme_t scheme; |
| | 761 | char tmp[_POSIX_PATH_MAX]; |
| 761 | 762 | |
| 762 | 763 | scheme = url_check_scheme (s); |
| … |
… |
|
| 780 | 781 | p = q; |
| 781 | 782 | } |
| 782 | | |
| 783 | | /* first attempt to collapse the pathname */ |
| 784 | | while (*p) |
| 785 | | { |
| 786 | | if (*p == '/' && p[1] == '/') |
| 787 | | { |
| 788 | | *q++ = '/'; |
| 789 | | p += 2; |
| 790 | | } |
| 791 | | else if (p[0] == '/' && p[1] == '.' && p[2] == '/') |
| 792 | | { |
| 793 | | *q++ = '/'; |
| 794 | | p += 3; |
| 795 | | } |
| 796 | | else |
| 797 | | *q++ = *p++; |
| 798 | | } |
| 799 | | *q = 0; |
| | 783 | |
| | 784 | /* cleanup path */ |
| | 785 | if (strstr (p, "//") || strstr (p, "/./")) |
| | 786 | { |
| | 787 | /* first attempt to collapse the pathname, this is more |
| | 788 | * lightweight than realpath() and doesn't resolve links |
| | 789 | */ |
| | 790 | while (*p) |
| | 791 | { |
| | 792 | if (*p == '/' && p[1] == '/') |
| | 793 | { |
| | 794 | *q++ = '/'; |
| | 795 | p += 2; |
| | 796 | } |
| | 797 | else if (p[0] == '/' && p[1] == '.' && p[2] == '/') |
| | 798 | { |
| | 799 | *q++ = '/'; |
| | 800 | p += 3; |
| | 801 | } |
| | 802 | else |
| | 803 | *q++ = *p++; |
| | 804 | } |
| | 805 | *q = 0; |
| | 806 | } |
| | 807 | else if (strstr (p, "..") && |
| | 808 | (scheme == U_UNKNOWN || scheme == U_FILE) && |
| | 809 | realpath (p, tmp)) |
| | 810 | strfcpy (p, tmp, buflen - (p - s)); |
| 800 | 811 | |
| 801 | 812 | if (mutt_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 && |
-
|
r5010
|
r5443
|
|
| 323 | 323 | SKIPWS (p); |
| 324 | 324 | strfcpy (fcc, p, fcclen); |
| 325 | | mutt_pretty_mailbox (fcc); |
| | 325 | mutt_pretty_mailbox (fcc, fcclen); |
| 326 | 326 | |
| 327 | 327 | /* remove the X-Mutt-Fcc: header field */ |
-
|
r5414
|
r5443
|
|
| 231 | 231 | void mutt_prepare_envelope (ENVELOPE *, int); |
| 232 | 232 | void mutt_unprepare_envelope (ENVELOPE *); |
| 233 | | void mutt_pretty_mailbox (char *); |
| | 233 | void mutt_pretty_mailbox (char *, size_t); |
| 234 | 234 | void mutt_pretty_size (char *, size_t, LOFF_T); |
| 235 | 235 | void mutt_pipe_message (HEADER *); |
-
|
r5348
|
r5443
|
|
| 255 | 255 | |
| 256 | 256 | strfcpy (path, aptr->content->filename, sizeof (path)); |
| 257 | | mutt_pretty_mailbox (path); |
| | 257 | mutt_pretty_mailbox (path, sizeof (path)); |
| 258 | 258 | mutt_format_s (dest, destlen, prefix, path); |
| 259 | 259 | } |
-
|
r5317
|
r5443
|
|
| 1506 | 1506 | |
| 1507 | 1507 | fcc_error = 0; /* reset value since we may have failed before */ |
| 1508 | | mutt_pretty_mailbox (fcc); |
| | 1508 | mutt_pretty_mailbox (fcc, sizeof (fcc)); |
| 1509 | 1509 | i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur); |
| 1510 | 1510 | if (i == -1) |
-
|
r5353
|
r5443
|
|
| 100 | 100 | { |
| 101 | 101 | strfcpy (tmp, Context->path, sizeof (tmp)); |
| 102 | | mutt_pretty_mailbox (tmp); |
| | 102 | mutt_pretty_mailbox (tmp, sizeof (tmp)); |
| 103 | 103 | } |
| 104 | 104 | else |