From 593b59c697342d00b7adf03296bf6db05bc2d44a Mon Sep 17 00:00:00 2001 From: Lars Wendler Date: Thu, 23 Jan 2014 08:30:07 +0100 Subject: [PATCH 1/7] Don't use --debug in Test--post-file.px Test--post-file.px fails when wget is compiled without debugging support. Signed-off-by: Lars Wendler --- tests/ChangeLog | 4 ++++ tests/Test--post-file.px | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index a873f7e8..67301691 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2014-01-23 Lars Wendler (tiny change) + + * Test--post-file.px: Do not fail when wget has no debug support. + 2013-11-04 Darshit Shah * Makefile.am: Add new tests introduced in last commit to diff --git a/tests/Test--post-file.px b/tests/Test--post-file.px index 1c017b72..1212af60 100755 --- a/tests/Test--post-file.px +++ b/tests/Test--post-file.px @@ -8,7 +8,7 @@ use HTTPTest; ############################################################################### -my $cmdline = $WgetTest::WGETPATH . " -d --post-file=nofile http://localhost:{{port}}/"; +my $cmdline = $WgetTest::WGETPATH . " --post-file=nofile http://localhost:{{port}}/"; my $expected_error_code = 3; From b65b9cb8c5f9e00a4bc35871cda07ea78874f01f Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sat, 1 Feb 2014 10:46:30 +0100 Subject: [PATCH 2/7] Turn --debug into no-op if compiled without debugging support --- src/ChangeLog | 10 ++++++++++ src/init.c | 2 -- src/main.c | 24 +++++++++++++++--------- src/options.h | 2 -- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 12f2a048..33eb5ed6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2014-01-29 Darshit Shah + + * main.c: Remove pre-processor variable WHEN_DEBUG + (option_data[]): Do not fail on --debug even if debug support is not + compiled in. + (main): Explicitly set opt.debug to false in case debugging support was not + compiled. + * init.c (commands[]): Support --debug wven when support is not compiled in. + * options.h: Same + 2014-01-17 Darshit Shah * init.c (commands[]): Add --no-config. diff --git a/src/init.c b/src/init.c index 43d5ae98..56fef508 100644 --- a/src/init.c +++ b/src/init.c @@ -157,9 +157,7 @@ static const struct { { "convertlinks", &opt.convert_links, cmd_boolean }, { "cookies", &opt.cookies, cmd_boolean }, { "cutdirs", &opt.cut_dirs, cmd_number }, -#ifdef ENABLE_DEBUG { "debug", &opt.debug, cmd_boolean }, -#endif { "defaultpage", &opt.default_page, cmd_string }, { "deleteafter", &opt.delete_after, cmd_boolean }, { "dirprefix", &opt.dir_prefix, cmd_directory }, diff --git a/src/main.c b/src/main.c index 2aa961da..6b6f72f3 100644 --- a/src/main.c +++ b/src/main.c @@ -128,12 +128,6 @@ static void print_version (void); # define IF_SSL(x) NULL #endif -#ifdef ENABLE_DEBUG -# define WHEN_DEBUG(x) x -#else -# define WHEN_DEBUG(x) NULL -#endif - struct cmdline_option { const char *long_name; char short_name; @@ -184,7 +178,7 @@ static struct cmdline_option option_data[] = { "content-on-error", 0, OPT_BOOLEAN, "contentonerror", -1 }, { "cookies", 0, OPT_BOOLEAN, "cookies", -1 }, { "cut-dirs", 0, OPT_VALUE, "cutdirs", -1 }, - { WHEN_DEBUG ("debug"), 'd', OPT_BOOLEAN, "debug", -1 }, + { "debug", 'd', OPT_BOOLEAN, "debug", -1 }, { "default-page", 0, OPT_VALUE, "defaultpage", -1 }, { "delete-after", 0, OPT_BOOLEAN, "deleteafter", -1 }, { "directories", 0, OPT_BOOLEAN, "dirstruct", -1 }, @@ -312,7 +306,6 @@ static struct cmdline_option option_data[] = #endif }; -#undef WHEN_DEBUG #undef IF_SSL /* Return a string that contains S with "no-" prepended. The string @@ -1206,9 +1199,22 @@ main (int argc, char **argv) nurl = argc - optind; + /* If we do not have Debug support compiled in AND Wget is invoked with the + * --debug switch, instead of failing, we silently turn it into a no-op. For + * this no-op, we explicitly set opt.debug to false and hence none of the + * Debug output messages will be printed. + */ +#ifndef ENABLE_DEBUG + if (opt.debug) + { + fprintf (stderr, _("Debugging support not compiled in. " + "Ignoring --debug flag.\n")); + opt.debug = false; + } +#endif + /* All user options have now been processed, so it's now safe to do interoption dependency checks. */ - if (opt.noclobber && opt.convert_links) { fprintf (stderr, diff --git a/src/options.h b/src/options.h index e00fadc7..06783cc3 100644 --- a/src/options.h +++ b/src/options.h @@ -156,9 +156,7 @@ struct options bool content_on_error; /* Do we output the content when the HTTP status code indicates a server error */ -#ifdef ENABLE_DEBUG bool debug; /* Debugging on/off */ -#endif #ifdef USE_WATT32 bool wdebug; /* Watt-32 tcp/ip debugging on/off */ From 59080465d170bfd15e5c405bf43a2aafd90586af Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 6 Feb 2014 18:34:25 +0100 Subject: [PATCH 3/7] configure.ac: update copyright years --- ChangeLog | 4 ++++ configure.ac | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eaa01f1..5d765478 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-02-06 Giuseppe Scrivano + + * configure.ac: Update copyright years. + 2013-12-22 Giuseppe Scrivano * gnulib: add git submodule. diff --git a/configure.ac b/configure.ac index b24588fc..c5437bf9 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Template file for GNU Autoconf -dnl Copyright (C) 1995, 1996, 1997, 2001, 2007, 2008, 2009, 2010, 2011 -dnl Free Software Foundation, Inc. +dnl Copyright (C) 1995, 1996, 1997, 2001, 2007, 2008, 2009, 2010, 2011, 2012, +dnl 2013, 2014 Free Software Foundation, Inc. dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by From d68295bdb1571589698ecd0f887f4ba6b72e4d30 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 6 Feb 2014 18:35:05 +0100 Subject: [PATCH 4/7] wget: move --version copyright year out of the localized string --- src/ChangeLog | 5 +++++ src/main.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 33eb5ed6..b7b67533 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-02-06 Giuseppe Scrivano + + * main.c (print_version): Move copyright year out of the localized + string and update it. + 2014-01-29 Darshit Shah * main.c: Remove pre-processor variable WHEN_DEBUG diff --git a/src/main.c b/src/main.c index 6b6f72f3..3ce7583f 100644 --- a/src/main.c +++ b/src/main.c @@ -952,8 +952,8 @@ print_version (void) /* TRANSLATORS: When available, an actual copyright character (circle-c) should be used in preference to "(C)". */ - if (fputs (_("\ -Copyright (C) 2011 Free Software Foundation, Inc.\n"), stdout) < 0) + if (printf (_("\ +Copyright (C) %s Free Software Foundation, Inc.\n"), "2014") < 0) exit (3); if (fputs (_("\ License GPLv3+: GNU GPL version 3 or later\n\ From 605eafa79243b1f08815792cd778e7b72a3f13e4 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 24 Feb 2014 22:08:53 +0100 Subject: [PATCH 5/7] gnulib: pull submodule forward --- ChangeLog | 5 +++++ gnulib | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5d765478..822dd941 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-24 Giuseppe Scrivano + + * gnulib: update module. + Reported by: Darshit Shah . + 2014-02-06 Giuseppe Scrivano * configure.ac: Update copyright years. diff --git a/gnulib b/gnulib index 0ac90c5a..1aed5599 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 0ac90c5a98030c998f3e1db3a0d7f19d4630b6b6 +Subproject commit 1aed559952395ff1eff24263701b349eb77a4e06 From 5bb2f4316571673291565f5ccd559f9abc8bc931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20P=C3=BDcha?= Date: Fri, 14 Feb 2014 15:44:51 +0100 Subject: [PATCH 6/7] URL-decode the filename parameter of Content-Disposition HTTP header if it is encoded --- src/ChangeLog | 15 +++++++++++++++ src/cookies.c | 6 +++--- src/http.c | 33 ++++++++++++++++++++++++++------- src/http.h | 2 +- src/url.c | 2 +- src/url.h | 1 + 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b7b67533..8c43faac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2014-02-14 Vladimír Pýcha (tiny change) + + * http.c (parse_content_disposition, extract_param) + (append_value_to_filename, digest_authentication_encode): URL-decode the + filename parameter of Content-Disposition HTTP header if it is encoded. This + is related to --content-disposition. + New parameter of extract_param(), "is_url_encoded". + Add argument NULL to the call of extract_param() in + digest_authentication_encode(). + * http.h: Add the new parameter to the declaration of extract_param(). + * cookies.c (parse_set_cookie, test_cookies): Add argument NULL to the calls + of extract_param(). + * url.c (url_unescape): Remove "static" modifier. + * url.h: Add declaration of url_unescape(). + 2014-02-06 Giuseppe Scrivano * main.c (print_version): Move copyright year out of the localized diff --git a/src/cookies.c b/src/cookies.c index 4efda88c..6ba7b5a5 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -346,7 +346,7 @@ parse_set_cookie (const char *set_cookie, bool silent) struct cookie *cookie = cookie_new (); param_token name, value; - if (!extract_param (&ptr, &name, &value, ';')) + if (!extract_param (&ptr, &name, &value, ';', NULL)) goto error; if (!value.b) goto error; @@ -360,7 +360,7 @@ parse_set_cookie (const char *set_cookie, bool silent) cookie->attr = strdupdelim (name.b, name.e); cookie->value = strdupdelim (value.b, value.e); - while (extract_param (&ptr, &name, &value, ';')) + while (extract_param (&ptr, &name, &value, ';', NULL)) { if (TOKEN_IS (name, "domain")) { @@ -1377,7 +1377,7 @@ test_cookies (void) param_token name, value; const char *ptr = data; int j = 0; - while (extract_param (&ptr, &name, &value, ';')) + while (extract_param (&ptr, &name, &value, ';', NULL)) { char *n = strdupdelim (name.b, name.e); char *v = strdupdelim (value.b, value.e); diff --git a/src/http.c b/src/http.c index 5715df65..690fcdec 100644 --- a/src/http.c +++ b/src/http.c @@ -1060,13 +1060,21 @@ modify_param_value (param_token *value, int encoding_type ) filename=\"foo bar\"", the first call to this function will return the token named "attachment" and no value, and the second call will return the token named "filename" and value "foo bar". The third - call will return false, indicating no more valid tokens. */ + call will return false, indicating no more valid tokens. + + is_url_encoded is an out parameter. If not NULL, a boolean value will be + stored into it, letting the caller know whether or not the extracted value is + URL-encoded. The caller can then decode it with url_unescape(), which however + performs decoding in-place. URL-encoding is used by RFC 2231 to support + non-US-ASCII characters in HTTP header values. */ bool extract_param (const char **source, param_token *name, param_token *value, - char separator) + char separator, bool *is_url_encoded) { const char *p = *source; + if (is_url_encoded) + *is_url_encoded = false; /* initializing the out parameter */ while (c_isspace (*p)) ++p; if (!*p) @@ -1125,6 +1133,8 @@ extract_param (const char **source, param_token *name, param_token *value, int param_type = modify_param_name(name); if (NOT_RFC2231 != param_type) { + if (RFC2231_ENCODING == param_type && is_url_encoded) + *is_url_encoded = true; modify_param_value(value, param_type); } return true; @@ -1137,13 +1147,16 @@ extract_param (const char **source, param_token *name, param_token *value, /* Appends the string represented by VALUE to FILENAME */ static void -append_value_to_filename (char **filename, param_token const * const value) +append_value_to_filename (char **filename, param_token const * const value, + bool is_url_encoded) { int original_length = strlen(*filename); int new_length = strlen(*filename) + (value->e - value->b); *filename = xrealloc (*filename, new_length+1); memcpy (*filename + original_length, value->b, (value->e - value->b)); (*filename)[new_length] = '\0'; + if (is_url_encoded) + url_unescape (*filename + original_length); } #undef MAX @@ -1176,7 +1189,9 @@ parse_content_disposition (const char *hdr, char **filename) { param_token name, value; *filename = NULL; - while (extract_param (&hdr, &name, &value, ';')) + bool is_url_encoded = false; + for ( ; extract_param (&hdr, &name, &value, ';', &is_url_encoded); + is_url_encoded = false) { int isFilename = BOUNDED_EQUAL_NO_CASE ( name.b, name.e, "filename" ); if ( isFilename && value.b != NULL) @@ -1192,9 +1207,13 @@ parse_content_disposition (const char *hdr, char **filename) continue; if (*filename) - append_value_to_filename (filename, &value); + append_value_to_filename (filename, &value, is_url_encoded); else - *filename = strdupdelim (value.b, value.e); + { + *filename = strdupdelim (value.b, value.e); + if (is_url_encoded) + url_unescape (*filename); + } } } @@ -3730,7 +3749,7 @@ digest_authentication_encode (const char *au, const char *user, realm = opaque = nonce = algorithm = qop = NULL; au += 6; /* skip over `Digest' */ - while (extract_param (&au, &name, &value, ',')) + while (extract_param (&au, &name, &value, ',', NULL)) { size_t i; size_t namelen = name.e - name.b; diff --git a/src/http.h b/src/http.h index 389456b1..21f1ed5c 100644 --- a/src/http.h +++ b/src/http.h @@ -43,7 +43,7 @@ typedef struct { /* A token consists of characters in the [b, e) range. */ const char *b, *e; } param_token; -bool extract_param (const char **, param_token *, param_token *, char); +bool extract_param (const char **, param_token *, param_token *, char, bool *); #endif /* HTTP_H */ diff --git a/src/url.c b/src/url.c index f554432c..f32c7269 100644 --- a/src/url.c +++ b/src/url.c @@ -169,7 +169,7 @@ static const unsigned char urlchr_table[256] = The transformation is done in place. If you need the original string intact, make a copy before calling this function. */ -static void +void url_unescape (char *s) { char *t = s; /* t - tortoise */ diff --git a/src/url.h b/src/url.h index cd3782b1..6d18ed81 100644 --- a/src/url.h +++ b/src/url.h @@ -101,6 +101,7 @@ struct url char *url_escape (const char *); char *url_escape_unsafe_and_reserved (const char *); +void url_unescape (char *); struct url *url_parse (const char *, int *, struct iri *iri, bool percent_encode); char *url_error (const char *, int); From 43c89ab7a5b20a84c0f393cb5393b68d3ce382fe Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 4 Mar 2014 17:25:13 +0100 Subject: [PATCH 7/7] http: aesthetic change --- src/ChangeLog | 4 ++++ src/http.c | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8c43faac..d3ac754c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-03-04 Giuseppe Scrivano + + * http.c (modify_param_value, extract_param): Aesthetic change. + 2014-02-14 Vladimír Pýcha (tiny change) * http.c (parse_content_disposition, extract_param) diff --git a/src/http.c b/src/http.c index 690fcdec..cd2bd15e 100644 --- a/src/http.c +++ b/src/http.c @@ -1040,7 +1040,7 @@ modify_param_name(param_token *name) static void modify_param_value (param_token *value, int encoding_type ) { - if (RFC2231_ENCODING == encoding_type) + if (encoding_type == RFC2231_ENCODING) { const char *delim = memrchr (value->b, '\'', value->e - value->b); if ( delim != NULL ) @@ -1073,6 +1073,7 @@ extract_param (const char **source, param_token *name, param_token *value, char separator, bool *is_url_encoded) { const char *p = *source; + int param_type; if (is_url_encoded) *is_url_encoded = false; /* initializing the out parameter */ @@ -1130,10 +1131,10 @@ extract_param (const char **source, param_token *name, param_token *value, } *source = p; - int param_type = modify_param_name(name); - if (NOT_RFC2231 != param_type) + param_type = modify_param_name(name); + if (param_type != NOT_RFC2231) { - if (RFC2231_ENCODING == param_type && is_url_encoded) + if (param_type == RFC2231_ENCODING && is_url_encoded) *is_url_encoded = true; modify_param_value(value, param_type); }