From: Micah Cowan Date: Fri, 16 May 2008 02:13:08 +0000 (-0700) Subject: Merge quote module stuff with current mainline. X-Git-Tag: v1.13~421^2~12^2~28 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=e72b57629bf49cdfd663002a8bb336a67b958979;hp=-c Merge quote module stuff with current mainline. --- e72b57629bf49cdfd663002a8bb336a67b958979 diff --combined ChangeLog index 166fd30e,f5b5d371..a0a295d8 --- a/ChangeLog +++ b/ChangeLog @@@ -1,11 -1,21 +1,29 @@@ +2008-05-12 Micah Cowan + + * NEWS: Translations and -N/-O. + +2008-04-30 Micah Cowan + + * NEWS: Added documentation for changes made in 1.11.2. + + 2008-04-14 Micah Cowan + + * GNUmakefile, lib/Makefile.am, lib/error.c, lib/error.h, + lib/exitfail.c, lib/exitfail.h, lib/getopt.c, lib/intprops.h, + lib/quote.c, lib/quote.h, lib/quotearg.c, lib/quotearg.h, + lib/stdlib.in.h, lib/strerror.c, lib/string.in.h, + lib/unistd.in.h, lib/wchar.in.h, lib/wctype.in.h, + lib/xalloc-die.c, lib/xalloc.h, lib/xmalloc.c, m4/error.m4, + m4/exitfail.m4, m4/extensions.m4, m4/gnulib-cache.m4, + m4/gnulib-comp.m4, m4/include_next.m4, m4/inline.m4, + m4/mbrtowc.m4, m4/mbstate_t.m4, m4/quote.m4, m4/quotearg.m4, + m4/stdlib_h.m4, m4/strerror.m4, m4/string_h.m4, m4/unistd_h.m4, + m4/wchar.m4, m4/wctype.m4, m4/wint_t.m4, m4/xalloc.m4, + md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-comp.m4, + md5/m4/include_next.m4, md5/m4/md5.m4, md5/m4/stdint.m4, + md5/md5.c, md5/md5.h, md5/stdint.in.h, md5/wchar.in.h: Update + from Gnulib, and add the "quote" module. + 2008-03-20 Micah Cowan * ABOUT-NLS: Reinstated, but with a message mentioning that diff --combined NEWS index 6b90b790,b87f9d98..24a097c4 --- a/NEWS +++ b/NEWS @@@ -6,40 -6,12 +6,33 @@@ See the end for copying conditions Please send GNU Wget bug reports to . -* Changes in Wget (MAINLINE). +* Changes in Wget 1.11.3 -** Gnulib is now used to provide code for certain portability aspects in -GNU Wget. +** Downgraded -N with -O to a warning, rather than an error. -** Wget uses Automake now as part of its build infrastructure. +** Translation updates + - * Changes in Wget (MAINLINE). - - ** Gnulib is now used to provide code for certain portability aspects in - GNU Wget. - - ** Wget uses Automake now as part of its build infrastructure. - +* Changes in Wget 1.11.2 + +** Fixed a problem in authenticating over HTTPS through a proxy. +(Regression in 1.11 over 1.10.2.) + +** The combination of -r or -p with -O, which was disallowed in 1.11, +has been downgraded to a warning in 1.11.2. (-O and -N, which was never +meaningful, is still an error.) + +** Further improvements to progress bar displays in non-English locales +(too many spaces could be inserted, causing the display to scroll). + +** Successive invocations of Wget on FTP URLS, with --no-remove-listing +and --continue, was causing Wget to append, rather than replace, +information in the .listing file, and thereby download the same files +multiple times. This has been fixed in 1.11.2. + +** Wget 1.11 no longer allowed ".." to persist at the beginning of URLs, +for improved conformance with RFC 3986. However, this behavior presents +problems for some FTP setups, and so they are now preserved again, for +FTP URLs only. * Changes in Wget 1.11.1. diff --combined src/ChangeLog index b8b466c0,c2db9da9..f223d359 --- a/src/ChangeLog +++ b/src/ChangeLog @@@ -1,82 -1,37 +1,116 @@@ + 2008-05-14 Micah Cowan + + * ftp.c (ftp_retrieve_list): Symlinks and other filenames + should be fully quoted. + +2008-05-12 Micah Cowan + + * main.c (main): Downgrade "-N with -O" to a warning, and switch + it off to avoid confusing messages. + +2008-04-30 Micah Cowan + + * progress.c (create_image): Fix glitch where too many spaces are + printed on lines that don't display the ETA, in multibyte + locales. + +2008-04-27 Rabin Vincent + + * http.c (http_loop): Fix return for the case where we don't + download a file because of -nc. + +2008-04-27 Micah Cowan + + * url.c (path_simplify): Go back to allowing leading ".." in + paths, but only for FTP URLs. + (test_path_simplify): Add scheme-specificness to tests, adapt for + mu_run_test. + + * test.c (all_tests): Add test_path_simplify. + + * main.c (main): Downgrade -r, -p with -O to a warning rather than + an error; elaborate just a bit more for other -O combination + cases. + +2008-04-26 Micah Cowan + + * http.c (gethttp): Move proxy CONNECT handling to below the + retry_with_auth label, to deal with properly reconnecting to + proxies when we need to authenticate. + +2008-04-25 Micah Cowan + + * Makefile.am: -I foo -> -Ifoo. + +2008-04-23 Micah Cowan + + * utils.c (test_dir_matches_p): Added a test for the case + described in issue #20518. + +2008-04-22 Jim Paris + + * openssl.c (ssl_init): Enable combined certificate/key in + single file (apparent regression from ~1.9). Resolves issue + #22767. + +2008-04-22 Steven Schubiger + + * http.c (print_response_line): Changed to make responses always + be logged, even in --quiet mode, if --server-response was + specified. This is to bring http.c's handling of the situation + in line with ftp.c's. + +2008-04-22 Pranab Shenoy + + * init.c: Added test_commands_sorted unit test to check is + commands are sorted. Fixes bug #21245. + + * test.c: Added test_commands_sorted to the test suite. + +2008-04-22 Rabin Vincent + + * ftp.c (ftp_get_listing): Only remove .listing if it has been + created. + +2008-04-22 Alain Guibert + + * test.h (mu_run_test): Move declaration before statements, for + C90 conformance. Fixes bug #22789. + +2008-04-22 Mike Frysinger + + * Makefile.am: Move @LIBS@ after other libraries, for better + static-linking support. Fixes bug #22143. + + 2008-04-16 Steven Schubiger + + * ftp.c: Use Gnulib's quote function for printing filenames and + such. + * connect.c: Likewise. + * convert.c: Likewise. + * cookies.c: Likewise. + * ftp-opie.c: Likewise. + * gnutls.c: Likewise. + * init.c: Likewise. + * log.c: Likewise. + * mswindows.c: Likewise. + * openssl.c: Likewise. + * progress.c: Likewise. + * recur.c: Likewise. + * res.c: Likewise. + * utils.c: Likewise. + + 2008-04-16 Steven Schubiger + + * sysdep.h: Comment the defines __EXTENSIONS__ and _GNU_SOURCE + out, because they're now defined independently by config.h. + + 2008-04-14 Steven Schubiger + + * http.c: Use Gnulib's quote function for printing filenames and + such. + * wget.h: #include "quote.h". + 2008-04-12 Rabin Vincent * mswindows.c (fake_fork_child): Don't create a logfile for diff --combined src/Makefile.am index d91ee764,4b351204..45175491 --- a/src/Makefile.am +++ b/src/Makefile.am @@@ -32,23 -32,23 +32,23 @@@ # The following line is losing on some versions of make! DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\" -LIBS = @LIBS@ @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ +LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ @LIBS@ bin_PROGRAMS = wget wget_SOURCES = cmpt.c connect.c convert.c cookies.c ftp.c ftp-basic.c \ ftp-ls.c hash.c host.c html-parse.c html-url.c http.c \ init.c log.c main.c netrc.c progress.c ptimer.c recur.c \ res.c retr.c snprintf.c spider.c url.c \ - utils.c xmalloc.c \ + utils.c \ connect.h convert.h cookies.h \ ftp.h gen-md5.h hash.h host.h html-parse.h \ http.h http-ntlm.h init.h log.h mswindows.h netrc.h \ options.h progress.h ptimer.h recur.h res.h retr.h \ - spider.h ssl.h sysdep.h url.h utils.h wget.h xmalloc.h + spider.h ssl.h sysdep.h url.h utils.h wget.h nodist_wget_SOURCES = version.c EXTRA_wget_SOURCES = mswindows.c - LDADD = $(ALLOCA) $(LIBOBJS) ../lib/libgnu.a @MD5_LDADD@ + LDADD = $(LIBOBJS) ../lib/libgnu.a @MD5_LDADD@ -AM_CPPFLAGS = -I $(top_srcdir)/lib @MD5_CPPFLAGS@ +AM_CPPFLAGS = -I$(top_srcdir)/lib @MD5_CPPFLAGS@ version.c: $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am echo 'const char *version_string = "@VERSION@"' > $@ @@@ -59,6 -59,6 +59,6 @@@ check_LIBRARIES = libunittest. libunittest_a_SOURCES = $(wget_SOURCES) test.c test.h nodist_libunittest_a_SOURCES = version.c libunittest_a_CPPFLAGS = -DTESTING -I$(top_srcdir)/lib - libunittest_a_LIBADD = $(ALLOCA) $(LIBOBJS) + libunittest_a_LIBADD = $(LIBOBJS) CLEANFILES = *~ *.bak core core.[0-9]* version.c diff --combined src/ftp.c index 5a9ecc6a,59ba1c16..0ecc6bcb --- a/src/ftp.c +++ b/src/ftp.c @@@ -300,7 -300,8 +300,8 @@@ getftp (struct url *u, wgint *len, wgin con->csock = -1; /* Second: Login with proper USER/PASS sequence. */ - logprintf (LOG_VERBOSE, _("Logging in as %s ... "), escnonprint (user)); + logprintf (LOG_VERBOSE, _("Logging in as %s ... "), + quotearg_style (escape_quoting_style, user)); if (opt.server_response) logputs (LOG_ALWAYS, "\n"); err = ftp_login (csock, logname, passwd); @@@ -545,7 -546,8 +546,8 @@@ Error in server response, closing contr } if (!opt.server_response) - logprintf (LOG_VERBOSE, "==> CWD %s ... ", escnonprint (target)); + logprintf (LOG_VERBOSE, "==> CWD %s ... ", + quotearg_style (escape_quoting_style, target)); err = ftp_cwd (csock, target); /* FTPRERR, WRITEFAILED, FTPNSFOD */ switch (err) @@@ -566,8 -568,8 +568,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"), - escnonprint (u->dir)); + logprintf (LOG_NOTQUIET, _("No such directory %s.\n\n"), + quote (u->dir)); fd_close (csock); con->csock = -1; return err; @@@ -588,7 -590,8 +590,8 @@@ if (opt.verbose) { if (!opt.server_response) - logprintf (LOG_VERBOSE, "==> SIZE %s ... ", escnonprint (u->file)); + logprintf (LOG_VERBOSE, "==> SIZE %s ... ", + quotearg_style (escape_quoting_style, u->file)); } err = ftp_size (csock, u->file, len); @@@ -795,7 -798,8 +798,8 @@@ Error in server response, closing contr { if (restval) logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_VERBOSE, "==> RETR %s ... ", escnonprint (u->file)); + logprintf (LOG_VERBOSE, "==> RETR %s ... ", + quotearg_style (escape_quoting_style, u->file)); } } @@@ -823,8 -827,8 +827,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such file `%s'.\n\n"), - escnonprint (u->file)); + logprintf (LOG_NOTQUIET, _("No such file %s.\n\n"), + quote (u->file)); fd_close (dtsock); fd_close (local_sock); return err; @@@ -870,8 -874,8 +874,8 @@@ Error in server response, closing contr return err; case FTPNSFOD: logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("No such file or directory `%s'.\n\n"), - "."); + logprintf (LOG_NOTQUIET, _("No such file or directory %s.\n\n"), + quote (".")); fd_close (dtsock); fd_close (local_sock); return err; @@@ -1063,7 -1067,8 +1067,8 @@@ char *p = strchr (line, '\0'); while (p > line && (p[-1] == '\n' || p[-1] == '\r')) *--p = '\0'; - logprintf (LOG_ALWAYS, "%s\n", escnonprint (line)); + logprintf (LOG_ALWAYS, "%s\n", + quotearg_style (escape_quoting_style, line)); xfree (line); } fclose (fp); @@@ -1094,7 -1099,7 +1099,7 @@@ ftp_loop_internal (struct url *u, struc if (opt.noclobber && file_exists_p (con->target)) { logprintf (LOG_VERBOSE, - _("File `%s' already there; not retrieving.\n"), con->target); + _("File %s already there; not retrieving.\n"), quote (con->target)); /* If the file is there, we suppose it's retrieved OK. */ return RETROK; } @@@ -1165,8 -1170,8 +1170,8 @@@ strcpy (tmp, " "); if (count > 1) sprintf (tmp, _("(try:%2d)"), count); - logprintf (LOG_VERBOSE, "--%s-- %s\n %s => `%s'\n", - tms, hurl, tmp, locf); + logprintf (LOG_VERBOSE, "--%s-- %s\n %s => %s\n", + tms, hurl, tmp, quote (locf)); #ifdef WINDOWS ws_changetitle (hurl); #endif @@@ -1234,8 -1239,8 +1239,8 @@@ con->csock = -1; } if (!opt.spider) - logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%s]\n\n"), - tms, tmrate, locf, number_to_static_string (len)); + logprintf (LOG_VERBOSE, _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, quote (locf), number_to_static_string (len)); if (!opt.verbose && !opt.quiet) { /* Need to hide the password from the URL. The `if' is here @@@ -1318,25 -1323,23 +1323,25 @@@ ftp_get_listing (struct url *u, ccon *c uf = url_file_name (u); lf = file_merge (uf, LIST_FILENAME); xfree (uf); - DEBUGP ((_("Using `%s' as listing tmp file.\n"), lf)); + DEBUGP ((_("Using %s as listing tmp file.\n"), quote (lf))); con->target = lf; err = ftp_loop_internal (u, NULL, con); con->target = old_target; if (err == RETROK) - *f = ftp_parse_ls (lf, con->rs); - else - *f = NULL; - if (opt.remove_listing) { - if (unlink (lf)) - logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno)); - else - logprintf (LOG_VERBOSE, _("Removed %s.\n"), quote (lf)); + *f = ftp_parse_ls (lf, con->rs); + if (opt.remove_listing) + { + if (unlink (lf)) + logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno)); + else - logprintf (LOG_VERBOSE, _("Removed `%s'.\n"), lf); ++ logprintf (LOG_VERBOSE, _("Removed %s.\n"), quote (lf)); + } } + else + *f = NULL; xfree (lf); con->cmd &= ~DO_LIST; return err; @@@ -1439,15 -1442,15 +1444,15 @@@ ftp_retrieve_list (struct url *u, struc /* Remote file is older, file sizes can be compared and are both equal. */ logprintf (LOG_VERBOSE, _("\ - Remote file no newer than local file `%s' -- not retrieving.\n"), con->target); + Remote file no newer than local file %s -- not retrieving.\n"), quote (con->target)); dlthis = false; } else if (eq_size) { /* Remote file is newer or sizes cannot be matched */ logprintf (LOG_VERBOSE, _("\ - Remote file is newer than local file `%s' -- retrieving.\n\n"), - con->target); + Remote file is newer than local file %s -- retrieving.\n\n"), + quote (con->target)); } else { @@@ -1489,14 -1492,15 +1494,15 @@@ The sizes do not match (local %s) -- re { logprintf (LOG_VERBOSE, _("\ Already have correct symlink %s -> %s\n\n"), - con->target, escnonprint (f->linkto)); + quote (con->target), + quote (f->linkto)); dlthis = false; break; } } } logprintf (LOG_VERBOSE, _("Creating symlink %s -> %s\n"), - con->target, escnonprint (f->linkto)); + quote (con->target), quote (f->linkto)); /* Unlink before creating symlink! */ unlink (con->target); if (symlink (f->linkto, con->target) == -1) @@@ -1505,8 -1509,8 +1511,8 @@@ } /* have f->linkto */ #else /* not HAVE_SYMLINK */ logprintf (LOG_NOTQUIET, - _("Symlinks not supported, skipping symlink `%s'.\n"), - con->target); + _("Symlinks not supported, skipping symlink %s.\n"), + quote (con->target)); #endif /* not HAVE_SYMLINK */ } else /* opt.retr_symlinks */ @@@ -1517,8 -1521,8 +1523,8 @@@ break; case FT_DIRECTORY: if (!opt.recursive) - logprintf (LOG_NOTQUIET, _("Skipping directory `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_NOTQUIET, _("Skipping directory %s.\n"), + quote (f->name)); break; case FT_PLAINFILE: /* Call the retrieve loop. */ @@@ -1527,7 -1531,7 +1533,7 @@@ break; case FT_UNKNOWN: logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"), - escnonprint (f->name)); + quote (f->name)); break; } /* switch */ @@@ -1632,8 -1636,8 +1638,8 @@@ ftp_retrieve_dirs (struct url *u, struc if (!accdir (newdir)) { logprintf (LOG_VERBOSE, _("\ - Not descending to `%s' as it is excluded/not-included.\n"), - escnonprint (newdir)); + Not descending to %s as it is excluded/not-included.\n"), + quote (newdir)); continue; } @@@ -1697,8 -1701,8 +1703,8 @@@ ftp_retrieve_glob (struct url *u, ccon { if (f->type != FT_DIRECTORY && !acceptable (f->name)) { - logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_VERBOSE, _("Rejecting %s.\n"), + quote (f->name)); f = delelement (f, &start); } else @@@ -1711,8 -1715,8 +1717,8 @@@ { if (has_insecure_name_p (f->name)) { - logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), - escnonprint (f->name)); + logprintf (LOG_VERBOSE, _("Rejecting %s.\n"), + quote (f->name)); f = delelement (f, &start); } else @@@ -1735,7 -1739,8 +1741,8 @@@ if (matchres == -1) { logprintf (LOG_NOTQUIET, _("Error matching %s against %s: %s\n"), - u->file, escnonprint (f->name), strerror (errno)); + u->file, quotearg_style (escape_quoting_style, f->name), + strerror (errno)); break; } if (matchres == FNM_NOMATCH) @@@ -1775,8 -1780,8 +1782,8 @@@ /* No luck. */ /* #### This message SUCKS. We should see what was the reason that nothing was retrieved. */ - logprintf (LOG_VERBOSE, _("No matches on pattern `%s'.\n"), - escnonprint (u->file)); + logprintf (LOG_VERBOSE, _("No matches on pattern %s.\n"), + quote (u->file)); } else /* GLOB_GETONE or GLOB_GETALL */ { @@@ -1841,13 -1846,13 +1848,13 @@@ ftp_loop (struct url *u, int *dt, struc else sz = -1; logprintf (LOG_NOTQUIET, - _("Wrote HTML-ized index to `%s' [%s].\n"), - filename, number_to_static_string (sz)); + _("Wrote HTML-ized index to %s [%s].\n"), + quote (filename), number_to_static_string (sz)); } else logprintf (LOG_NOTQUIET, - _("Wrote HTML-ized index to `%s'.\n"), - filename); + _("Wrote HTML-ized index to %s.\n"), + quote (filename)); } xfree (filename); } diff --combined src/http.c index 129359ca,5b04fe4a..0252d342 --- a/src/http.c +++ b/src/http.c @@@ -403,13 -403,13 +403,13 @@@ maybe_send_basic_creds (const char *hos else if (basic_authed_hosts && hash_table_contains(basic_authed_hosts, hostname)) { - DEBUGP(("Found `%s' in basic_authed_hosts.\n", hostname)); + DEBUGP(("Found %s in basic_authed_hosts.\n", quote (hostname))); do_challenge = true; } else { - DEBUGP(("Host `%s' has not issued a general basic challenge.\n", - hostname)); + DEBUGP(("Host %s has not issued a general basic challenge.\n", + quote (hostname))); } if (do_challenge) { @@@ -430,7 -430,7 +430,7 @@@ register_basic_auth_host (const char *h if (!hash_table_contains(basic_authed_hosts, hostname)) { hash_table_put (basic_authed_hosts, xstrdup(hostname), NULL); - DEBUGP(("Inserted `%s' into basic_authed_hosts\n", hostname)); + DEBUGP(("Inserted %s into basic_authed_hosts\n", quote (hostname))); } } @@@ -810,7 -810,8 +810,8 @@@ print_response_line(const char *prefix { char *copy; BOUNDED_TO_ALLOCA(b, e, copy); - logprintf (LOG_ALWAYS, "%s%s\n", prefix, escnonprint(copy)); - logprintf (LOG_VERBOSE, "%s%s\n", prefix, ++ logprintf (LOG_ALWAYS, "%s%s\n", prefix, + quotearg_style (escape_quoting_style, copy)); } /* Print the server response, line by line, omitting the trailing CRLF @@@ -1497,6 -1498,41 +1498,6 @@@ gethttp (struct url *u, struct http_sta basic_auth_finished = maybe_send_basic_creds(u->host, user, passwd, req); } - proxyauth = NULL; - if (proxy) - { - char *proxy_user, *proxy_passwd; - /* For normal username and password, URL components override - command-line/wgetrc parameters. With proxy - authentication, it's the reverse, because proxy URLs are - normally the "permanent" ones, so command-line args - should take precedence. */ - if (opt.proxy_user && opt.proxy_passwd) - { - proxy_user = opt.proxy_user; - proxy_passwd = opt.proxy_passwd; - } - else - { - proxy_user = proxy->user; - proxy_passwd = proxy->passwd; - } - /* #### This does not appear right. Can't the proxy request, - say, `Digest' authentication? */ - if (proxy_user && proxy_passwd) - proxyauth = basic_authentication_encode (proxy_user, proxy_passwd); - - /* If we're using a proxy, we will be connecting to the proxy - server. */ - conn = proxy; - - /* Proxy authorization over SSL is handled below. */ -#ifdef HAVE_SSL - if (u->scheme != SCHEME_HTTPS) -#endif - request_set_header (req, "Proxy-Authorization", proxyauth, rel_value); - } - /* Generate the Host header, HOST:PORT. Take into account that: - Broken server-side software often doesn't recognize the PORT @@@ -1544,8 -1580,8 +1545,8 @@@ post_data_size = file_size (opt.post_file_name); if (post_data_size == -1) { - logprintf (LOG_NOTQUIET, _("POST data file `%s' missing: %s\n"), - opt.post_file_name, strerror (errno)); + logprintf (LOG_NOTQUIET, _("POST data file %s missing: %s\n"), + quote (opt.post_file_name), strerror (errno)); post_data_size = 0; } } @@@ -1567,41 -1603,6 +1568,41 @@@ without authorization header fails. (Expected to happen at least for the Digest authorization scheme.) */ + proxyauth = NULL; + if (proxy) + { + char *proxy_user, *proxy_passwd; + /* For normal username and password, URL components override + command-line/wgetrc parameters. With proxy + authentication, it's the reverse, because proxy URLs are + normally the "permanent" ones, so command-line args + should take precedence. */ + if (opt.proxy_user && opt.proxy_passwd) + { + proxy_user = opt.proxy_user; + proxy_passwd = opt.proxy_passwd; + } + else + { + proxy_user = proxy->user; + proxy_passwd = proxy->passwd; + } + /* #### This does not appear right. Can't the proxy request, + say, `Digest' authentication? */ + if (proxy_user && proxy_passwd) + proxyauth = basic_authentication_encode (proxy_user, proxy_passwd); + + /* If we're using a proxy, we will be connecting to the proxy + server. */ + conn = proxy; + + /* Proxy authorization over SSL is handled below. */ +#ifdef HAVE_SSL + if (u->scheme != SCHEME_HTTPS) +#endif + request_set_header (req, "Proxy-Authorization", proxyauth, rel_value); + } + keep_alive = false; /* Establish the connection. */ @@@ -1629,7 -1630,8 +1630,8 @@@ sock = pconn.socket; using_ssl = pconn.ssl; logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"), - escnonprint (pconn.host), pconn.port); + quotearg_style (escape_quoting_style, pconn.host), + pconn.port); DEBUGP (("Reusing fd %d.\n", sock)); if (pconn.authorized) /* If the connection is already authorized, the "Basic" @@@ -1641,8 -1643,8 +1643,8 @@@ { request_free (req); logprintf(LOG_NOTQUIET, - _("%s: unable to resolve host address `%s'\n"), - exec_name, relevant->host); + _("%s: unable to resolve host address %s\n"), + exec_name, quote (relevant->host)); return HOSTERR; } } @@@ -1717,7 -1719,7 +1719,7 @@@ { failed_tunnel: logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"), - message ? escnonprint (message) : "?"); + message ? quotearg_style (escape_quoting_style, message) : "?"); xfree_null (message); return CONSSLERR; } @@@ -1795,7 -1797,7 +1797,7 @@@ statcode = resp_status (resp, &message); if (!opt.server_response) logprintf (LOG_VERBOSE, "%2d %s\n", statcode, - message ? escnonprint (message) : ""); + message ? quotearg_style (escape_quoting_style, message) : ""); else { logprintf (LOG_VERBOSE, "\n"); @@@ -1826,7 -1828,7 +1828,7 @@@ /* If opt.noclobber is turned on and file already exists, do not retrieve the file */ logprintf (LOG_VERBOSE, _("\ - File `%s' already there; not retrieving.\n\n"), hs->local_file); + File %s already there; not retrieving.\n\n"), quote (hs->local_file)); /* If the file is there, we suppose it's retrieved OK. */ *dt |= RETROKF; @@@ -2205,7 -2207,7 +2207,7 @@@ logputs (LOG_VERBOSE, opt.ignore_length ? _("ignored") : _("unspecified")); if (type) - logprintf (LOG_VERBOSE, " [%s]\n", escnonprint (type)); + logprintf (LOG_VERBOSE, " [%s]\n", quotearg_style (escape_quoting_style, type)); else logputs (LOG_VERBOSE, "\n"); } @@@ -2274,8 -2276,8 +2276,8 @@@ /* Print fetch message, if opt.verbose. */ if (opt.verbose) { - logprintf (LOG_NOTQUIET, _("Saving to: `%s'\n"), - HYPHENP (hs->local_file) ? "STDOUT" : hs->local_file); + logprintf (LOG_NOTQUIET, _("Saving to: %s\n"), + HYPHENP (hs->local_file) ? quote ("STDOUT") : quote (hs->local_file)); } /* This confuses the timestamping code that checks for file size. @@@ -2379,8 -2381,8 +2381,8 @@@ http_loop (struct url *u, char **newloc /* If opt.noclobber is turned on and file already exists, do not retrieve the file */ logprintf (LOG_VERBOSE, _("\ - File `%s' already there; not retrieving.\n\n"), - hstat.local_file); + File %s already there; not retrieving.\n\n"), + quote (hstat.local_file)); /* If the file is there, we suppose it's retrieved OK. */ *dt |= RETROKF; @@@ -2389,8 -2391,7 +2391,8 @@@ if (has_html_suffix_p (hstat.local_file)) *dt |= TEXTHTML; - return RETRUNNEEDED; + ret = RETROK; + goto exit; } /* Reset the counter. */ @@@ -2508,8 -2509,8 +2510,8 @@@ Spider mode enabled. Check if remote fi case FWRITEERR: case FOPENERR: /* Another fatal error. */ logputs (LOG_VERBOSE, "\n"); - logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"), - hstat.local_file, strerror (errno)); + logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"), + quote (hstat.local_file), strerror (errno)); case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: case SSLINITFAILED: case CONTNOTSUPPORTED: /* Fatal errors just return from the function. */ @@@ -2577,7 -2578,8 +2579,8 @@@ Remote file does not exist -- broken li else { logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), - tms, hstat.statcode, escnonprint (hstat.error)); + tms, hstat.statcode, + quotearg_style (escape_quoting_style, hstat.error)); } logputs (LOG_VERBOSE, "\n"); ret = WRONGCODE; @@@ -2631,8 -2633,8 +2634,8 @@@ Last-modified header invalid -- time-st || hstat.orig_file_size == hstat.contlen) { logprintf (LOG_VERBOSE, _("\ - Server file no newer than local file `%s' -- not retrieving.\n\n"), - hstat.orig_file_name); + Server file no newer than local file %s -- not retrieving.\n\n"), + quote (hstat.orig_file_name)); ret = RETROK; goto exit; } @@@ -2735,8 -2737,8 +2738,8 @@@ Remote file exists.\n\n")) if (*dt & RETROKF) { logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s/%s]\n\n"), - tms, tmrate, hstat.local_file, + _("%s (%s) - %s saved [%s/%s]\n\n"), + tms, tmrate, quote (hstat.local_file), number_to_static_string (hstat.len), number_to_static_string (hstat.contlen)); logprintf (LOG_NONVERBOSE, @@@ -2766,8 -2768,8 +2769,8 @@@ if (*dt & RETROKF) { logprintf (LOG_VERBOSE, - _("%s (%s) - `%s' saved [%s]\n\n"), - tms, tmrate, hstat.local_file, + _("%s (%s) - %s saved [%s]\n\n"), + tms, tmrate, quote (hstat.local_file), number_to_static_string (hstat.len)); logprintf (LOG_NONVERBOSE, "%s URL:%s [%s] -> \"%s\" [%d]\n", diff --combined src/init.c index ab86c781,e079df95..fcb7c2cc --- a/src/init.c +++ b/src/init.c @@@ -478,8 -478,8 +478,8 @@@ run_wgetrc (const char *file ++errcnt; break; case line_unknown_command: - fprintf (stderr, _("%s: Unknown command `%s' in %s at line %d.\n"), - exec_name, com, file, ln); + fprintf (stderr, _("%s: Unknown command %s in %s at line %d.\n"), + exec_name, quote (com), file, ln); ++errcnt; break; case line_empty: @@@ -524,8 -524,8 +524,8 @@@ initialize (void if (!strcmp (file, SYSTEM_WGETRC)) { fprintf (stderr, _("\ - %s: Warning: Both system and user wgetrc point to `%s'.\n"), - exec_name, file); + %s: Warning: Both system and user wgetrc point to %s.\n"), + exec_name, quote (file)); } else #endif @@@ -676,8 -676,8 +676,8 @@@ run_command (const char *opt xfree (val); break; default: - fprintf (stderr, _("%s: Invalid --execute command `%s'\n"), - exec_name, opt); + fprintf (stderr, _("%s: Invalid --execute command %s\n"), + exec_name, quote (opt)); exit (2); } } @@@ -721,8 -721,8 +721,8 @@@ cmd_boolean (const char *com, const cha else { fprintf (stderr, - _("%s: %s: Invalid boolean `%s'; use `on' or `off'.\n"), - exec_name, com, val); + _("%s: %s: Invalid boolean %s; use `on' or `off'.\n"), + exec_name, com, quote (val)); return false; } @@@ -738,8 -738,8 +738,8 @@@ cmd_number (const char *com, const cha if (!simple_atoi (val, val + strlen (val), place) || *(int *) place < 0) { - fprintf (stderr, _("%s: %s: Invalid number `%s'.\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid number %s.\n"), + exec_name, com, quote (val)); return false; } return true; @@@ -969,8 -969,8 +969,8 @@@ cmd_bytes (const char *com, const char double byte_value; if (!parse_bytes_helper (val, &byte_value)) { - fprintf (stderr, _("%s: %s: Invalid byte value `%s'\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid byte value %s\n"), + exec_name, com, quote (val)); return false; } *(wgint *)place = (wgint)byte_value; @@@ -988,8 -988,8 +988,8 @@@ cmd_bytes_sum (const char *com, const c double byte_value; if (!parse_bytes_helper (val, &byte_value)) { - fprintf (stderr, _("%s: %s: Invalid byte value `%s'\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid byte value %s\n"), + exec_name, com, quote (val)); return false; } *(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value; @@@ -1013,8 -1013,8 +1013,8 @@@ cmd_time (const char *com, const char * if (val == end) { err: - fprintf (stderr, _("%s: %s: Invalid time period `%s'\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid time period %s\n"), + exec_name, com, quote (val)); return false; } @@@ -1067,7 -1067,7 +1067,7 @@@ cmd_cert_type (const char *com, const c }; int ok = decode_string (val, choices, countof (choices), place); if (!ok) - fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid value %s.\n"), exec_name, com, quote (val)); return ok; } #endif @@@ -1104,8 -1104,8 +1104,8 @@@ cmd_spec_header (const char *com, cons if (!check_user_specified_header (val)) { - fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid header %s.\n"), + exec_name, com, quote (val)); return false; } opt.user_headers = vec_append (opt.user_headers, val); @@@ -1157,7 -1157,7 +1157,7 @@@ cmd_spec_prefer_family (const char *com int prefer_family = prefer_ipv4; int ok = decode_string (val, choices, countof (choices), &prefer_family); if (!ok) - fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid value %s.\n"), exec_name, com, quote (val)); opt.prefer_family = prefer_family; return ok; } @@@ -1170,8 -1170,8 +1170,8 @@@ cmd_spec_progress (const char *com, con { if (!valid_progress_implementation_p (val)) { - fprintf (stderr, _("%s: %s: Invalid progress type `%s'.\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid progress type %s.\n"), + exec_name, com, quote (val)); return false; } xfree_null (opt.progress_type); @@@ -1229,8 -1229,8 +1229,8 @@@ cmd_spec_restrict_file_names (const cha else { fprintf (stderr, - _("%s: %s: Invalid restriction `%s', use [unix|windows],[lowercase|uppercase],[nocontrol].\n"), - exec_name, com, val); + _("%s: %s: Invalid restriction %s, use [unix|windows],[lowercase|uppercase],[nocontrol].\n"), + exec_name, com, quote (val)); return false; } @@@ -1260,7 -1260,7 +1260,7 @@@ cmd_spec_secure_protocol (const char *c }; int ok = decode_string (val, choices, countof (choices), place); if (!ok) - fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid value %s.\n"), exec_name, com, quote (val)); return ok; } #endif @@@ -1285,8 -1285,8 +1285,8 @@@ cmd_spec_useragent (const char *com, co /* Disallow embedded newlines. */ if (strchr (val, '\n')) { - fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"), - exec_name, com, val); + fprintf (stderr, _("%s: %s: Invalid value %s.\n"), + exec_name, com, quote (val)); return false; } xfree_null (opt.useragent); @@@ -1530,29 -1530,6 +1530,29 @@@ cleanup (void #ifdef TESTING +const char * +test_commands_sorted() +{ + int prev_idx = 0, next_idx = 1; + int command_count = countof (commands) - 1; + int cmp = 0; + while (next_idx <= command_count) + { + cmp = strcasecmp (commands[prev_idx].name, commands[next_idx].name); + if (cmp > 0) + { + mu_assert ("FAILED", false); + break; + } + else + { + prev_idx ++; + next_idx ++; + } + } + return NULL; +} + const char * test_cmd_spec_restrict_file_names() { diff --combined src/openssl.c index 1f19a6f6,8a5cc0ed..f5239ede --- a/src/openssl.c +++ b/src/openssl.c @@@ -210,13 -210,6 +210,13 @@@ ssl_init ( than examining the error stack after a failed SSL_connect. */ SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_NONE, NULL); + /* Use the private key from the cert file unless otherwise specified. */ + if (opt.cert_file && !opt.private_key) + { + opt.private_key = opt.cert_file; + opt.private_key_type = opt.cert_type; + } + if (opt.cert_file) if (SSL_CTX_use_certificate_file (ssl_ctx, opt.cert_file, key_type_to_ssl_type (opt.cert_type)) @@@ -502,7 -495,7 +502,7 @@@ ssl_check_certificate (int fd, const ch if (!cert) { logprintf (LOG_NOTQUIET, _("%s: No certificate presented by %s.\n"), - severity, escnonprint (host)); + severity, quotearg_style (escape_quoting_style, host)); success = false; goto no_cert; /* must bail out since CERT is NULL */ } @@@ -512,7 -505,8 +512,8 @@@ char *subject = X509_NAME_oneline (X509_get_subject_name (cert), 0, 0); char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0); DEBUGP (("certificate:\n subject: %s\n issuer: %s\n", - escnonprint (subject), escnonprint (issuer))); + quotearg_style (escape_quoting_style, subject), + quotearg_style (escape_quoting_style, issuer))); OPENSSL_free (subject); OPENSSL_free (issuer); } @@@ -522,8 -516,9 +523,9 @@@ { char *issuer = X509_NAME_oneline (X509_get_issuer_name (cert), 0, 0); logprintf (LOG_NOTQUIET, - _("%s: cannot verify %s's certificate, issued by `%s':\n"), - severity, escnonprint (host), escnonprint (issuer)); + _("%s: cannot verify %s's certificate, issued by %s:\n"), + severity, quotearg_style (escape_quoting_style, host), + quote (issuer)); /* Try to print more user-friendly (and translated) messages for the frequent verification errors. */ switch (vresult) @@@ -573,21 -568,21 +575,21 @@@ if (!pattern_match (common_name, host)) { logprintf (LOG_NOTQUIET, _("\ - %s: certificate common name `%s' doesn't match requested host name `%s'.\n"), - severity, escnonprint (common_name), escnonprint (host)); + %s: certificate common name %s doesn't match requested host name %s.\n"), + severity, quote (common_name), quote (host)); success = false; } if (success) DEBUGP (("X509 certificate successfully verified and matches host %s\n", - escnonprint (host))); + quotearg_style (escape_quoting_style, host))); X509_free (cert); no_cert: if (opt.check_cert && !success) logprintf (LOG_NOTQUIET, _("\ To connect to %s insecurely, use `--no-check-certificate'.\n"), - escnonprint (host)); + quotearg_style (escape_quoting_style, host)); /* Allow --no-check-cert to disable certificate checking. */ return opt.check_cert ? success : true; diff --combined src/progress.c index 9e009993,8b9b1013..de108e76 --- a/src/progress.c +++ b/src/progress.c @@@ -453,8 -453,8 +453,8 @@@ dot_set_params (const char *params } else fprintf (stderr, - _("Invalid dot style specification `%s'; leaving unchanged.\n"), - params); + _("Invalid dot style specification %s; leaving unchanged.\n"), + quote (params)); } /* "Thermometer" (bar) progress. */ @@@ -797,14 -797,15 +797,14 @@@ count_cols (const char *mbs # define count_cols(mbs) ((int)(strlen(mbs))) #endif -/* Translation note: "ETA" is English-centric, but this must - be short, ideally 3 chars. Abbreviate if necessary. */ -static const char eta_str[] = N_(" eta %s"); -static const char *eta_trans; -static int bytes_cols_diff; - const char * -get_eta (void) +get_eta (int *bcd) { + /* Translation note: "ETA" is English-centric, but this must + be short, ideally 3 chars. Abbreviate if necessary. */ + static const char eta_str[] = N_(" eta %s"); + static const char *eta_trans; + static int bytes_cols_diff; if (eta_trans == NULL) { int nbytes; @@@ -828,9 -829,6 +828,9 @@@ bytes_cols_diff = nbytes - ncols; } + if (bcd != NULL) + *bcd = bytes_cols_diff; + return eta_trans; } @@@ -883,10 -881,6 +883,10 @@@ create_image (struct bar_progress *bp, int dlbytes_size = 1 + MAX (size_grouped_len, 11); int progress_size = bp->width - (4 + 2 + dlbytes_size + 8 + 14); + /* The difference between the number of bytes used, + and the number of columns used. */ + int bytes_cols_diff = 0; + if (progress_size < 5) progress_size = 0; @@@ -1029,8 -1023,7 +1029,8 @@@ bp->last_eta_time = dl_total_time; } - sprintf (p, get_eta(), eta_to_human_short (eta, false)); + sprintf (p, get_eta(&bytes_cols_diff), + eta_to_human_short (eta, false)); move_to_end (p); } else if (bp->total_length > 0) @@@ -1042,16 -1035,11 +1042,16 @@@ else { /* When the download is done, print the elapsed time. */ + int nbytes; + int ncols; /* Note to translators: this should not take up more room than available here. Abbreviate if necessary. */ strcpy (p, _(" in ")); - move_to_end (p); /* not p+=6, think translations! */ + nbytes = strlen (p); + ncols = count_cols (p); + bytes_cols_diff = nbytes - ncols; + p += nbytes; if (dl_total_time >= 10) strcpy (p, eta_to_human_short ((int) (dl_total_time + 0.5), false)); else diff --combined src/utils.c index 85a83355,c4f78fe4..a6c84491 --- a/src/utils.c +++ b/src/utils.c @@@ -88,6 -88,32 +88,32 @@@ as that of the covered work. * #include "test.h" #endif + static void + memfatal (const char *context, long attempted_size) + { + /* Make sure we don't try to store part of the log line, and thus + call malloc. */ + log_set_save_context (false); + + /* We have different log outputs in different situations: + 1) output without bytes information + 2) output with bytes information */ + if (attempted_size == UNKNOWN_ATTEMPTED_SIZE) + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate enough memory; memory exhausted.\n"), + exec_name, context); + } + else + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"), + exec_name, context, attempted_size); + } + + exit (1); + } + /* Utility function: like xstrdup(), but also lowercases S. */ char * @@@ -348,7 -374,7 +374,7 @@@ fork_to_background (void /* parent, no error */ printf (_("Continuing in background, pid %d.\n"), (int) pid); if (logfile_changed) - printf (_("Output will be written to `%s'.\n"), opt.lfilename); + printf (_("Output will be written to %s.\n"), quote (opt.lfilename)); exit (0); /* #### should we use _exit()? */ } @@@ -394,8 -420,8 +420,8 @@@ remove_link (const char *file DEBUGP (("Unlinking %s (symlink).\n", file)); err = unlink (file); if (err != 0) - logprintf (LOG_VERBOSE, _("Failed to unlink symlink `%s': %s\n"), - file, strerror (errno)); + logprintf (LOG_VERBOSE, _("Failed to unlink symlink %s: %s\n"), + quote (file), strerror (errno)); } return err; } @@@ -2205,8 -2231,6 +2231,8 @@@ test_dir_matches_p( { { "*/*COMPLETE", NULL, NULL }, "foo/!COMPLETE", true }, { { "/dir with spaces", NULL, NULL }, "dir with spaces", true }, { { "/dir*with*spaces", NULL, NULL }, "dir with spaces", true }, + { { "/Tmp/has", NULL, NULL }, "/Tmp/has space", false }, + { { "/Tmp/has", NULL, NULL }, "/Tmp/has,comma", false }, }; for (i = 0; i < countof(test_array); ++i)