On Thu, Aug 4, 2016 at 9:53 PM, Tim Ruehsen <[email protected]> wrote:
> On Thursday, August 4, 2016 5:38:22 PM CEST Jeffery To wrote: > > Hi, > > > > I'm trying to set the hsts-file option from a wgetrc file, but Wget > (1.17.1 > > on Ubuntu 16.04 x86_64) tells me it is an unknown command. (The same > option > > passed on the command line yields no errors.) > > > > I looked into the source (albeit a very cursory examination), and it > > appears that in init.c (run_wgetrc), the command name is taken from each > > line of the wgetrc file (parse_line), hyphens and underscores are removed > > from the name (dehyphen), and then searched for in the commands array > > (command_by_name). > > > > Currently, the name for the hsts-file option in the commands array is > > "hsts-file" (note the included hyphen), and so it would be impossible to > > match this command from a wgetrc file. (There are several other commands > > that have hyphens in their names in the commands array, e.g. > > "if-modified-since" and several Metalink options, which I would expect to > > also suffer from this issue, though I haven't tested them individually.) > > > > Is this analysis correct, and if so, would a patch that removes the > hyphens > > from command names (and from the corresponding data field in the > > option_data array in main.c) be acceptable? > > Hi Jeff, > > thanks for your analysis, which is correct. > > A patch would be very appreciated. > Since it will (well, I guess so) be a 'trivial' patch, no FSF copyright > assignment is needed. So, just go ahead ! > > Regards, Tim > Thanks Tim - attached is the patch. Let me know if I should instead send it inline in a new email. Best regards, Jeff
From fc0163bf083b242bd1f4ec4bea90f69b16f68e30 Mon Sep 17 00:00:00 2001 From: Jeffery To <[email protected]> Date: Thu, 4 Aug 2016 23:00:03 +0800 Subject: [PATCH] Remove hyphens from command names * src/init.c: Remove hyphens from command names * src/main.c: Likewise Options with hyphens (or underscores) in their command name cannot be set in a wgetrc file. Signed-off-by: Jeffery To <[email protected]> --- src/init.c | 10 +++++----- src/main.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/init.c b/src/init.c index 06d2e44..9538ae7 100644 --- a/src/init.c +++ b/src/init.c @@ -210,7 +210,7 @@ static const struct { { "header", NULL, cmd_spec_header }, #ifdef HAVE_HSTS { "hsts", &opt.hsts, cmd_boolean }, - { "hsts-file", &opt.hsts_file, cmd_file }, + { "hstsfile", &opt.hsts_file, cmd_file }, #endif { "htmlextension", &opt.adjust_extension, cmd_boolean }, /* deprecated */ { "htmlify", NULL, cmd_spec_htmlify }, @@ -223,7 +223,7 @@ static const struct { #endif { "httpsproxy", &opt.https_proxy, cmd_string }, { "httpuser", &opt.http_user, cmd_string }, - { "if-modified-since", &opt.if_modified_since, cmd_boolean }, + { "ifmodifiedsince", &opt.if_modified_since, cmd_boolean }, { "ignorecase", &opt.ignore_case, cmd_boolean }, { "ignorelength", &opt.ignore_length, cmd_boolean }, { "ignoretags", &opt.ignore_tags, cmd_vector }, @@ -234,7 +234,7 @@ static const struct { #endif { "input", &opt.input_filename, cmd_file }, #ifdef HAVE_METALINK - { "input-metalink", &opt.input_metalink, cmd_file }, + { "inputmetalink", &opt.input_metalink, cmd_file }, #endif { "iri", &opt.enable_iri, cmd_boolean }, { "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean }, @@ -245,7 +245,7 @@ static const struct { { "login", &opt.ftp_user, cmd_string },/* deprecated*/ { "maxredirect", &opt.max_redirect, cmd_number }, #ifdef HAVE_METALINK - { "metalink-over-http", &opt.metalink_over_http, cmd_boolean }, + { "metalinkoverhttp", &opt.metalink_over_http, cmd_boolean }, #endif { "method", &opt.method, cmd_string_uppercase }, { "mirror", NULL, cmd_spec_mirror }, @@ -267,7 +267,7 @@ static const struct { { "postfile", &opt.post_file_name, cmd_file }, { "preferfamily", NULL, cmd_spec_prefer_family }, #ifdef HAVE_METALINK - { "preferred-location", &opt.preferred_location, cmd_string }, + { "preferredlocation", &opt.preferred_location, cmd_string }, #endif { "preservepermissions", &opt.preserve_perm, cmd_boolean }, #ifdef HAVE_SSL diff --git a/src/main.c b/src/main.c index 4d69e03..96a37f5 100644 --- a/src/main.c +++ b/src/main.c @@ -321,7 +321,7 @@ static struct cmdline_option option_data[] = { "host-directories", 0, OPT_BOOLEAN, "addhostdir", -1 }, #ifdef HAVE_HSTS { "hsts", 0, OPT_BOOLEAN, "hsts", -1}, - { "hsts-file", 0, OPT_VALUE, "hsts-file", -1 }, + { "hsts-file", 0, OPT_VALUE, "hstsfile", -1 }, #endif { "html-extension", 'E', OPT_BOOLEAN, "adjustextension", -1 }, /* deprecated */ { "htmlify", 0, OPT_BOOLEAN, "htmlify", -1 }, @@ -340,7 +340,7 @@ static struct cmdline_option option_data[] = #endif { "input-file", 'i', OPT_VALUE, "input", -1 }, #ifdef HAVE_METALINK - { "input-metalink", 0, OPT_VALUE, "input-metalink", -1 }, + { "input-metalink", 0, OPT_VALUE, "inputmetalink", -1 }, #endif { "iri", 0, OPT_BOOLEAN, "iri", -1 }, { "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 }, @@ -351,7 +351,7 @@ static struct cmdline_option option_data[] = { "rejected-log", 0, OPT_VALUE, "rejectedlog", -1 }, { "max-redirect", 0, OPT_VALUE, "maxredirect", -1 }, #ifdef HAVE_METALINK - { "metalink-over-http", 0, OPT_BOOLEAN, "metalink-over-http", -1 }, + { "metalink-over-http", 0, OPT_BOOLEAN, "metalinkoverhttp", -1 }, #endif { "method", 0, OPT_VALUE, "method", -1 }, { "mirror", 'm', OPT_BOOLEAN, "mirror", -1 }, @@ -370,7 +370,7 @@ static struct cmdline_option option_data[] = { "post-file", 0, OPT_VALUE, "postfile", -1 }, { "prefer-family", 0, OPT_VALUE, "preferfamily", -1 }, #ifdef HAVE_METALINK - { "preferred-location", 0, OPT_VALUE, "preferred-location", -1 }, + { "preferred-location", 0, OPT_VALUE, "preferredlocation", -1 }, #endif { "preserve-permissions", 0, OPT_BOOLEAN, "preservepermissions", -1 }, { IF_SSL ("private-key"), 0, OPT_VALUE, "privatekey", -1 }, @@ -410,7 +410,7 @@ static struct cmdline_option option_data[] = { "strict-comments", 0, OPT_BOOLEAN, "strictcomments", -1 }, { "timeout", 'T', OPT_VALUE, "timeout", -1 }, { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 }, - { "if-modified-since", 0, OPT_BOOLEAN, "if-modified-since", -1 }, + { "if-modified-since", 0, OPT_BOOLEAN, "ifmodifiedsince", -1 }, { "tries", 't', OPT_VALUE, "tries", -1 }, { "unlink", 0, OPT_BOOLEAN, "unlink", -1 }, { "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 }, -- 2.7.4
