Subject: mpack: allow user to specify filename replacement character Package: mpack Version: 1.6-7 Severity: wishlist Tags: patch
*** Please type your report below this line *** When the attachment's suggested filename has spaces or other undesirable characters, munpack replaces them with 'X'. ThisXisXugly, and I'd prefer to let the user specify a replacement character. Here is a patch that adds an option [-r character] so that munpack -r- would produce "This-is-better". The default is still 'X', so as not to disrupt any expectations. The manual page and usage string have been updated accordingly. Thanks. -- System Information: Debian Release: 6.0.5 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-0.bpo.2-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages mpack depends on: ii libc6 2.11.3-3 Embedded GNU C Library: Shared lib mpack recommends no packages. Versions of packages mpack suggests: ii exim4-daemon-light [mail 4.72-6+squeeze2 lightweight Exim MTA (v4) daemon pn inews <none> (no description available) -- no debconf information -- Patch below diff --git a/unixos.c b/unixos.c index 22a1080..f1db411 100644 --- a/unixos.c +++ b/unixos.c @@ -50,6 +50,7 @@ extern int errno; int overwrite_files = 0; int didchat; +char replacement_char = 'X'; /* The name of the file we're writing */ static char *output_fname = 0; @@ -194,13 +195,13 @@ FILE *os_newtypedfile(char *fname, char *contentType, int flags, params contentP for (p=fname; *p; p++) { if (*p == '/') { if (!strncmp(p, "/../", 4)) { - p[1] = p[2] = 'X'; + p[1] = p[2] = replacement_char; } *p = '\0'; (void) mkdir(fname, 0777); *p = '/'; } - else if (!isprint(*p) || strchr(BADCHARS, *p)) *p = 'X'; + else if (!isprint(*p) || strchr(BADCHARS, *p)) *p = replacement_char; } if (!fname[0]) { diff --git a/unixunpk.c b/unixunpk.c index e58882d..584b4ac 100644 --- a/unixunpk.c +++ b/unixunpk.c @@ -31,6 +31,7 @@ extern int overwrite_files; extern int didchat; +extern char replacement_char; int quiet; void usage(void); @@ -43,7 +44,7 @@ int main(int argc, char **argv) FILE *file; int extractText = 0; - while ((opt = getopt(argc, argv, "qftC:")) != EOF) { + while ((opt = getopt(argc, argv, "qftr:C:")) != EOF) { switch (opt) { case 'f': overwrite_files = 1; @@ -57,6 +58,11 @@ int main(int argc, char **argv) extractText = 1; break; + case 'r': + replacement_char = optarg[0]; + printf("Replacement: '%c'\n", replacement_char); + break; + case 'C': if (chdir(optarg)) { perror(optarg); @@ -102,7 +108,7 @@ int main(int argc, char **argv) void usage(void) { fprintf(stderr, "munpack version %s\n", MPACK_VERSION); - fprintf(stderr, "usage: munpack [-f] [-q] [-t] [-C directory] [files...]\n"); + fprintf(stderr, "usage: munpack [-f] [-q] [-t] [-r character] [-C directory] [files...]\n"); exit(1); } diff --git a/unixunpk.man b/unixunpk.man index 459fc0c..16e182f 100644 --- a/unixunpk.man +++ b/unixunpk.man @@ -13,6 +13,10 @@ munpack \- unpack messages in MIME or split-uuencode format .B \-t ] [ +.B \-r +.I character +] +[ .B \-C .I directory ] @@ -59,6 +63,11 @@ default, text parts that do not have a filename parameter do not get unpacked. This option effectively disables the ".desc" file feature for MIME messages. .TP +.BI \-r " character" +If the suggested filename contains invalid characters, they are +replaced with this character. The default replacement character is +"X". +.TP .BI \-C " directory" Change the current directory to .I directory -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/debian-bugs-dist