summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-09-24 14:46:45 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-09-24 14:47:09 +0300
commitdd13dedfe0580e391e2a082ff9d1ac842292a4eb (patch)
tree86b069ee5df16dcefea963819597f557e32499e2
parent81cd471c86dafffd89d517e5b9dcf2be3c16b1e5 (diff)
downloadmailutils-dd13dedfe0580e391e2a082ff9d1ac842292a4eb.tar.gz
mailutils-dd13dedfe0580e391e2a082ff9d1ac842292a4eb.tar.bz2
Fix hex (%XX) expansion in URLs.
* mailbox/url.c (url_parse0): Take three arguments. Return in the third one a boolean indicating whether to expand %XX notations in the URL. Do not decode absolute file names and pipes. (mu_url_parse): Use this value to decide. * movemail/movemail.c (main): In emacs mode: force UNIX mbox format as a default. Send debugging output to stderr.
-rw-r--r--mailbox/url.c35
-rw-r--r--movemail/movemail.c8
2 files changed, 28 insertions, 15 deletions
diff --git a/mailbox/url.c b/mailbox/url.c
index 1b833bf3f..f46fbc14f 100644
--- a/mailbox/url.c
+++ b/mailbox/url.c
@@ -40,7 +40,7 @@
40#define AC2(a,b) a ## b 40#define AC2(a,b) a ## b
41#define AC4(a,b,c,d) a ## b ## c ## d 41#define AC4(a,b,c,d) a ## b ## c ## d
42 42
43static int url_parse0 (mu_url_t, char *, size_t *poff); 43static int url_parse0 (mu_url_t, char *, size_t *poff, int *decode);
44 44
45static int 45static int
46parse_query (const char *query, 46parse_query (const char *query,
@@ -286,7 +286,8 @@ mu_url_parse (mu_url_t url)
286 struct _mu_url u; 286 struct _mu_url u;
287 size_t pstart; 287 size_t pstart;
288 mu_secret_t newsec; 288 mu_secret_t newsec;
289 289 int want_decode;
290
290 if (!url || !url->name) 291 if (!url || !url->name)
291 return EINVAL; 292 return EINVAL;
292 293
@@ -301,7 +302,7 @@ mu_url_parse (mu_url_t url)
301 if (!n) 302 if (!n)
302 return ENOMEM; 303 return ENOMEM;
303 304
304 err = url_parse0 (&u, n, &pstart); 305 err = url_parse0 (&u, n, &pstart, &want_decode);
305 306
306 if (!err) 307 if (!err)
307 { 308 {
@@ -331,17 +332,18 @@ mu_url_parse (mu_url_t url)
331 though. 332 though.
332 */ 333 */
333 334
334#define UALLOC(X) \ 335#define UALLOC(X) \
335 if (u.X && u.X[0] && (url->X = mu_url_decode(u.X)) == 0) \ 336 if (u.X && u.X[0] && \
336 { \ 337 !(url->X = (want_decode ? mu_url_decode (u.X) : strdup (u.X)))) \
337 err = ENOMEM; \ 338 { \
338 goto CLEANUP; \ 339 err = ENOMEM; \
339 } \ 340 goto CLEANUP; \
340 else \ 341 } \
341 { \ 342 else \
342 /* Set zero-length strings to NULL. */ \ 343 { \
343 u.X = NULL; \ 344 /* Set zero-length strings to NULL. */ \
344 } 345 u.X = NULL; \
346 }
345 347
346 UALLOC (scheme); 348 UALLOC (scheme);
347 UALLOC (user); 349 UALLOC (user);
@@ -420,7 +422,7 @@ Is this required to be % quoted, though? I hope so!
420*/ 422*/
421 423
422static int 424static int
423url_parse0 (mu_url_t u, char *name, size_t *poff) 425url_parse0 (mu_url_t u, char *name, size_t *poff, int *decode)
424{ 426{
425 char *start = name; 427 char *start = name;
426 char *p; /* pointer into name */ 428 char *p; /* pointer into name */
@@ -432,11 +434,13 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
432 if (name[0] == '/') 434 if (name[0] == '/')
433 { 435 {
434 u->scheme = "file"; 436 u->scheme = "file";
437 *decode = 0;
435 } 438 }
436 else if (name[0] == '|') 439 else if (name[0] == '|')
437 { 440 {
438 int rc; 441 int rc;
439 u->scheme = "prog"; 442 u->scheme = "prog";
443 *decode = 0;
440 rc = mu_argcv_get (name + 1, NULL, NULL, &u->qargc, &u->qargv); 444 rc = mu_argcv_get (name + 1, NULL, NULL, &u->qargc, &u->qargv);
441 if (rc == 0) 445 if (rc == 0)
442 { 446 {
@@ -448,6 +452,7 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
448 } 452 }
449 else 453 else
450 { 454 {
455 *decode = 1;
451 /* Parse out the SCHEME. */ 456 /* Parse out the SCHEME. */
452 p = strchr (name, ':'); 457 p = strchr (name, ':');
453 if (p == NULL) 458 if (p == NULL)
diff --git a/movemail/movemail.c b/movemail/movemail.c
index afb83e8ae..4e7bdb986 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -760,6 +760,14 @@ main (int argc, char **argv)
760 return 1; 760 return 1;
761 } 761 }
762 762
763 if (emacs_mode)
764 {
765 /* Undo the effect of configuration options that may affect
766 the interaction with Emacs. */
767 mu_registrar_set_default_record (mu_mbox_record);
768 mu_debug_default_printer = mu_debug_stderr_printer;
769 }
770
763 atexit (close_mailboxes); 771 atexit (close_mailboxes);
764 772
765 source_name = argv[0]; 773 source_name = argv[0];

Return to:

Send suggestions and report system problems to the System administrator.