mirror of
https://github.com/openzim/zimit.git
synced 2025-09-26 22:33:27 -04:00
Merge pull request #310 from openzim/invalid_user_agent
Strip user-agent whitespaces and ignore empty user agents
This commit is contained in:
commit
7806aeba63
@ -558,6 +558,16 @@ def get_node_cmd_line(args):
|
|||||||
"logging",
|
"logging",
|
||||||
]:
|
]:
|
||||||
value = getattr(args, arg)
|
value = getattr(args, arg)
|
||||||
|
if arg == "userAgent":
|
||||||
|
# - strip leading whitespace which are not allowed on some websites
|
||||||
|
# - strip trailing whitespace which are either not allowed if no suffix is
|
||||||
|
# used, or duplicate with the automatically added one if a suffix is there
|
||||||
|
# - value is None when userAgent is not passed
|
||||||
|
if value:
|
||||||
|
value = value.strip()
|
||||||
|
if not value:
|
||||||
|
# ignore empty userAgent arg and keep crawler default value if empty
|
||||||
|
continue
|
||||||
if value is None or (isinstance(value, bool) and value is False):
|
if value is None or (isinstance(value, bool) and value is False):
|
||||||
continue
|
continue
|
||||||
node_cmd.append("--" + arg)
|
node_cmd.append("--" + arg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user