Merge remote-tracking branch 'origin/master' into parallel-wget

This commit is contained in:
Giuseppe Scrivano 2014-03-05 11:22:39 +01:00
commit 35ab8cdd7a
14 changed files with 104 additions and 34 deletions

View File

@ -1,3 +1,12 @@
2014-02-24 Giuseppe Scrivano <gscrivan@redhat.com>
* gnulib: update module.
Reported by: Darshit Shah <darnir@gmail.com>.
2014-02-06 Giuseppe Scrivano <gscrivan@redhat.com>
* configure.ac: Update copyright years.
2013-12-22 Giuseppe Scrivano <gscrivan@redhat.com>
* gnulib: add git submodule.

View File

@ -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

2
gnulib

@ -1 +1 @@
Subproject commit 0ac90c5a98030c998f3e1db3a0d7f19d4630b6b6
Subproject commit 1aed559952395ff1eff24263701b349eb77a4e06

View File

@ -1,3 +1,37 @@
2014-03-04 Giuseppe Scrivano <gscrivan@redhat.com>
* http.c (modify_param_value, extract_param): Aesthetic change.
2014-02-14 Vladimír Pýcha <vpycha@gmail.com> (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 <gscrivan@redhat.com>
* main.c (print_version): Move copyright year out of the localized
string and update it.
2014-01-29 Darshit Shah <darnir@gmail.com>
* 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 <darnir@gmail.com>
* init.c (commands[]): Add --no-config.

View File

@ -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);

View File

@ -1044,7 +1044,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 )
@ -1064,13 +1064,22 @@ 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;
int param_type;
if (is_url_encoded)
*is_url_encoded = false; /* initializing the out parameter */
while (c_isspace (*p)) ++p;
if (!*p)
@ -1126,9 +1135,11 @@ 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 (param_type == RFC2231_ENCODING && is_url_encoded)
*is_url_encoded = true;
modify_param_value(value, param_type);
}
return true;
@ -1141,13 +1152,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
@ -1180,7 +1194,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)
@ -1196,9 +1212,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);
}
}
}
@ -4045,7 +4065,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;

View File

@ -45,7 +45,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 */

View File

@ -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 },

View File

@ -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 },
@ -321,7 +315,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
@ -981,8 +974,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\
@ -1228,9 +1221,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,

View File

@ -161,9 +161,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 */

View File

@ -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 */

View File

@ -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);

View File

@ -1,3 +1,7 @@
2014-01-23 Lars Wendler <polynomial-c@gentoo.org> (tiny change)
* Test--post-file.px: Do not fail when wget has no debug support.
2013-11-04 Darshit Shah <darnir@gmail.com>
* Makefile.am: Add new tests introduced in last commit to

View File

@ -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;