fix: catch UnicodeDecodeError on special character usernames#2840
Open
juliosuas wants to merge 1 commit intosherlock-project:masterfrom
Open
fix: catch UnicodeDecodeError on special character usernames#2840juliosuas wants to merge 1 commit intosherlock-project:masterfrom
juliosuas wants to merge 1 commit intosherlock-project:masterfrom
Conversation
When scanning usernames containing non-ASCII characters (e.g. 'Émile'), some sites return redirect Location headers encoded in Latin-1 instead of UTF-8. The requests library raises UnicodeDecodeError when processing these redirects, causing Sherlock to crash. This fix catches UnicodeEncodeError and UnicodeDecodeError in get_response() alongside the existing requests exception handlers, allowing the scan to gracefully skip the affected site and continue checking the remaining targets. Fixes sherlock-project#2730
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.
Problem
When scanning usernames containing non-ASCII characters (e.g.
Émile), Sherlock crashes with aUnicodeDecodeError:This happens because some sites return HTTP redirect
Locationheaders encoded in Latin-1 (ISO-8859-1) rather than UTF-8. Therequestslibrary raisesUnicodeDecodeErrorwhen trying to decode these headers during redirect resolution.Fix
Add
UnicodeEncodeErrorandUnicodeDecodeErrorto the exception handlers inget_response(), alongside the existingrequestsexception handlers. This allows Sherlock to gracefully skip the problematic site (marking it as an error) and continue scanning the remaining targets instead of crashing.Testing
Before (crashes midway through scan):
After (completes full scan, skipping sites with encoding issues):
Fixes #2730