| 1 |
Description: allow user to specify filename replacement character. |
| 2 |
Author: Christopher League <[email protected]> |
| 3 |
Bug-Debian: https://bugs.debian.org/676422 |
| 4 |
Last-Update: 2012-06-06 |
| 5 |
--- mpack-1.6.orig/unixos.c |
| 6 |
+++ mpack-1.6/unixos.c |
| 7 |
@@ -50,6 +50,7 @@ extern int errno; |
| 8 |
|
| 9 |
int overwrite_files = 0; |
| 10 |
int didchat; |
| 11 |
+char replacement_char = 'X'; |
| 12 |
|
| 13 |
/* The name of the file we're writing */ |
| 14 |
static char *output_fname = 0; |
| 15 |
@@ -194,13 +195,13 @@ FILE *os_newtypedfile(char *fname, char |
| 16 |
for (p=fname; *p; p++) { |
| 17 |
if (*p == '/') { |
| 18 |
if (!strncmp(p, "/../", 4)) { |
| 19 |
|
| 20 |
+ p[1] = p[2] = replacement_char; |
| 21 |
} |
| 22 |
*p = '\0'; |
| 23 |
(void) mkdir(fname, 0777); |
| 24 |
*p = '/'; |
| 25 |
} |
| 26 |
|
| 27 |
+ else if (!isprint(*p) || strchr(BADCHARS, *p)) *p = replacement_char; |
| 28 |
} |
| 29 |
|
| 30 |
if (!fname[0]) { |
| 31 |
--- mpack-1.6.orig/unixunpk.c |
| 32 |
+++ mpack-1.6/unixunpk.c |
| 33 |
@@ -31,6 +31,7 @@ |
| 34 |
|
| 35 |
extern int overwrite_files; |
| 36 |
extern int didchat; |
| 37 |
+extern char replacement_char; |
| 38 |
int quiet; |
| 39 |
|
| 40 |
void usage(void); |
| 41 |
@@ -43,7 +44,7 @@ int main(int argc, char **argv) |
| 42 |
FILE *file; |
| 43 |
int extractText = 0; |
| 44 |
|
| 45 |
|
| 46 |
+ while ((opt = getopt(argc, argv, "qftr:C:")) != EOF) { |
| 47 |
switch (opt) { |
| 48 |
case 'f': |
| 49 |
overwrite_files = 1; |
| 50 |
@@ -57,6 +58,11 @@ int main(int argc, char **argv) |
| 51 |
extractText = 1; |
| 52 |
break; |
| 53 |
|
| 54 |
+ case 'r': |
| 55 |
+ replacement_char = optarg[0]; |
| 56 |
+ printf("Replacement: '%c'\n", replacement_char); |
| 57 |
+ break; |
| 58 |
+ |
| 59 |
case 'C': |
| 60 |
if (chdir(optarg)) { |
| 61 |
perror(optarg); |
| 62 |
@@ -102,7 +108,7 @@ int main(int argc, char **argv) |
| 63 |
|
| 64 |
void usage(void) { |
| 65 |
fprintf(stderr, "munpack version %s\n", MPACK_VERSION); |
| 66 |
|
| 67 |
+ fprintf(stderr, "usage: munpack [-f] [-q] [-t] [-r character] [-C directory] [files...]\n"); |
| 68 |
exit(1); |
| 69 |
} |
| 70 |
|
| 71 |
--- mpack-1.6.orig/unixunpk.man |
| 72 |
+++ mpack-1.6/unixunpk.man |
| 73 |
@@ -13,6 +13,10 @@ munpack \- unpack messages in MIME or sp |
| 74 |
.B \-t |
| 75 |
] |
| 76 |
[ |
| 77 |
+.B \-r |
| 78 |
+.I character |
| 79 |
+] |
| 80 |
+[ |
| 81 |
.B \-C |
| 82 |
.I directory |
| 83 |
] |
| 84 |
@@ -59,6 +63,11 @@ default, text parts that do not have a f |
| 85 |
unpacked. This option effectively disables the ".desc" file feature |
| 86 |
for MIME messages. |
| 87 |
.TP |
| 88 |
+.BI \-r " character" |
| 89 |
+If the suggested filename contains invalid characters, they are |
| 90 |
+replaced with this character. The default replacement character is |
| 91 |
+"X". |
| 92 |
+.TP |
| 93 |
.BI \-C " directory" |
| 94 |
Change the current directory to |
| 95 |
.I directory |