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

fix value error in some cases while parsing date #145

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

b3n4kh
Copy link
Contributor

@b3n4kh b3n4kh commented Apr 5, 2024

While parsing specific URLs like: https://www.mozilla.org/en-US/security/advisories/mfsa2024-17/

In this way:

from htmldate import find_date
find_date("https://www.mozilla.org/en-US/security/advisories/mfsa2024-17/")

The current regex will extract 2024-17 as a date and while parsing it inside search_page

It throws: ValueError: month must be in 1..12

This PR mitigates this, while remaining backwards compatible with all other test cases.

Right now for the test URL it only returns the fallback to the first year of the copyright mention.

@adbar adbar mentioned this pull request Apr 8, 2024
Copy link

codecov bot commented Apr 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.09%. Comparing base (b5b95da) to head (2cde8dd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #145   +/-   ##
=======================================
  Coverage   99.09%   99.09%           
=======================================
  Files           8        8           
  Lines         880      880           
=======================================
  Hits          872      872           
  Misses          8        8           

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

@adbar
Copy link
Owner

adbar commented Apr 8, 2024

Hi @b3n4kh, thanks for the fix and the tests!

I also wanted to address the issue so in the end I'll merge both PRs by making your pattern more restrictive.

@adbar adbar merged commit bde42c8 into adbar:master Apr 8, 2024
22 checks passed
@b3n4kh b3n4kh deleted the feature/fix_valueerror branch April 9, 2024 06:51
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.

None yet

2 participants