-
Notifications
You must be signed in to change notification settings - Fork 780
Fix: handle non-UTF-8 input in util.py #1069
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
Open
dmcgrath19
wants to merge
20
commits into
Future-House:main
Choose a base branch
from
dmcgrath19:dmcgrath19-patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5675e97
Image reader and image support in `gather_evidence` (#1046)
jamesbraza d1cde22
Preventing Greek name from crashing `DocDetails` creation (#1048)
jamesbraza 0caa926
Better invalid name logs (#1049)
jamesbraza f71d023
Multimodal PDF support (#1047)
jamesbraza d3760c9
Fix paperqa/configs link in README.md (#1051)
chrisranderson 948423f
Fixing all broken links, `pymarkdown` (#1052)
jamesbraza d34543e
Documenting `DocMetadataTask`/`MetadataProvider` (#1050)
jamesbraza beb838e
chore(deps): lock file maintenance (#1053)
renovate[bot] 81ea858
chore(deps): update actions/checkout action to v5 (#1058)
renovate[bot] 193feb6
chore(deps): update actions/download-artifact action to v5 (#1059)
renovate[bot] 72b7f26
Moved `mypy` to use `local` hook to unsilence it on missing dependenc…
jamesbraza 6801155
Removed dead `patch` from `test_add_clinical_trials_to_docs` (#1056)
jamesbraza 34ceb70
Restored `UnpaywallProvider` by updating expected response (#1057)
jamesbraza fab944a
Refreshed `test_crossref_journalquality_fields_filtering` cassette (#…
jamesbraza 4862764
Updating `journal_quality.csv` from script (#1061)
jamesbraza 2d58202
Better lookup failure message in `Settings.from_name` (#1064)
jamesbraza 62afb8c
Lower bibtex logging to debug (#1067)
mskarlin 687ce40
Fix: handle non-UTF-8 input in util.py
dmcgrath19 7a88d42
Add comments to utf-8 error handling
dmcgrath19 46e21d6
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix: handle non-UTF-8 input in util.py
Chemistry papers such as DOIs 10.26434/chemrxiv-2025-1x058-v2 and 10.26434/chemrxiv-2025-3lwn2 contain files that sometimes throw errors due to non-UTF-8 characters during parsing. This change updates the MD5 hashing line to replace problematic characters during UTF-8 encoding, making the parsing process more robust and preventing interruptions caused by encoding errors.
- Loading branch information
commit 687ce4023a4b7ba2a69a3f8e7611645fca6e1305
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,7 @@ def strings_similarity(s1: str, s2: str, case_insensitive: bool = True) -> float | |
|
|
||
| def hexdigest(data: str | bytes) -> str: | ||
| if isinstance(data, str): | ||
| return hashlib.md5(data.encode("utf-8")).hexdigest() # noqa: S324 | ||
| return hashlib.md5(data.encode("utf-8", errors="replace")).hexdigest() # noqa: S324 | ||
|
||
| return hashlib.md5(data).hexdigest() # noqa: S324 | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 'replace' error handling may silently mask data corruption issues. Consider logging when characters are replaced or using 'ignore' if replacement characters could affect hash consistency. This change could cause different hash values for the same logical content depending on encoding issues.