Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip user-agent whitespaces and ignore empty user agents #310

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

benoit74
Copy link
Collaborator

@benoit74 benoit74 commented Jun 3, 2024

Fix #281

Rationale:

  • userAgent deserves a special handling to remove whitespaces:
    • leading are not allowed on some websites
    • trailing are useless especially when using in conjunction with a suffix which already adds a space
  • refuse empty userAgent which are bad:
  • no real reason to permit it
  • and it causes issues once combined with a userAgentSuffix which adds a leading space
  • do not generalize to refuse empty CLI arg since it might be needed in some occasion where ones want to blank the crawler default value

@benoit74 benoit74 self-assigned this Jun 3, 2024
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 14.17%. Comparing base (957e52c) to head (9366669).

Files Patch % Lines
src/zimit/zimit.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #310      +/-   ##
==========================================
- Coverage   14.45%   14.17%   -0.29%     
==========================================
  Files           1        1              
  Lines         249      254       +5     
  Branches       35       38       +3     
==========================================
  Hits           36       36              
- Misses        213      218       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benoit74 benoit74 force-pushed the invalid_user_agent branch from 0f39911 to b734c23 Compare June 3, 2024 09:01
@benoit74 benoit74 marked this pull request as ready for review June 3, 2024 09:14
@benoit74 benoit74 requested a review from rgaudin June 3, 2024 09:14
@benoit74
Copy link
Collaborator Author

benoit74 commented Jun 3, 2024

I propose to continue to not care about codecov issues for now, I've opened #311 so that this is fixed in 2.1 (minimal coverage + sufficient code structure to be able to require proper testing of next modifications)

@benoit74 benoit74 requested a review from rgaudin June 3, 2024 13:23
@benoit74 benoit74 force-pushed the invalid_user_agent branch from 9e6c345 to 9366669 Compare June 3, 2024 15:06
@benoit74 benoit74 merged commit 7806aeb into main Jun 3, 2024
5 of 7 checks passed
@benoit74 benoit74 deleted the invalid_user_agent branch June 3, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid leading whitespace in User-Agent header
2 participants