Skip to content

Commit

Permalink
Strip user-agent leading whitespaces and ignore empty user agents
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Jun 3, 2024
1 parent 957e52c commit 0f39911
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/zimit/zimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ def get_node_cmd_line(args):
"logging",
]:
value = getattr(args, arg)
if arg == "userAgent":
# strip leading whitespace which are not allowed on some websites
value = value.strip()

Check warning on line 563 in src/zimit/zimit.py

View check run for this annotation

Codecov / codecov/patch

src/zimit/zimit.py#L563

Added line #L563 was not covered by tests
if not value:
# ignore empty userAgent arg and keep crawler default value if empty
continue

Check warning on line 566 in src/zimit/zimit.py

View check run for this annotation

Codecov / codecov/patch

src/zimit/zimit.py#L566

Added line #L566 was not covered by tests
if value is None or (isinstance(value, bool) and value is False):
continue
node_cmd.append("--" + arg)
Expand Down

0 comments on commit 0f39911

Please sign in to comment.