fix: handle encoding errors in sitemap URL seeding gracefully#1784
Open
Br1an67 wants to merge 1 commit intounclecode:mainfrom
Open
fix: handle encoding errors in sitemap URL seeding gracefully#1784Br1an67 wants to merge 1 commit intounclecode:mainfrom
Br1an67 wants to merge 1 commit intounclecode:mainfrom
Conversation
Add per-URL error handling in the producer loop so a single URL with problematic characters (e.g. zero-width spaces) doesn't crash the entire sitemap processing. Also strip zero-width space (U+200B) and BOM (U+FEFF) characters from sitemap URLs during normalization. Fixes unclecode#1542
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When a sitemap contains URLs with Unicode characters like zero-width spaces (
U+200B), the producer inasync_url_seeder.pycrashes with aUnicodeEncodeErroron Windows (charmap codec), which terminates URL seeding prematurely.This PR:
U+200B) and BOM (U+FEFF) characters from sitemap URLs during normalization in both_iter_sitemap_content()and_iter_sitemap()Fixes #1542
List of files changed and why
crawl4ai/async_url_seeder.py— AddedUnicodeEncodeErrorcatch in producer loop; strip invisible Unicode chars in_normalize_loc()How Has This Been Tested?
Verified that the producer continues processing after encountering URLs with zero-width spaces, and that
_normalize_loccorrectly strips invisible characters.Checklist: