-
-
Notifications
You must be signed in to change notification settings - Fork 840
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 httpx is not encoding with symbol '%s' (#3140) #3141
Conversation
httpx/_urlparse.py
Outdated
i = 0 | ||
while i < len(string): | ||
char = string[i] | ||
if char in NON_ESCAPED_CHARS: | ||
i += 1 | ||
continue | ||
# Check if the character is a start of a valid percent-encoded sequence | ||
elif ( | ||
char == "%" | ||
and i + 2 < len(string) | ||
and string[i + 1 : i + 3].isalnum() | ||
and len(string[i + 1 : i + 3]) == 2 | ||
): | ||
i += 3 | ||
else: | ||
return False | ||
|
||
return True |
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.
i = 0 | |
while i < len(string): | |
char = string[i] | |
if char in NON_ESCAPED_CHARS: | |
i += 1 | |
continue | |
# Check if the character is a start of a valid percent-encoded sequence | |
elif ( | |
char == "%" | |
and i + 2 < len(string) | |
and string[i + 1 : i + 3].isalnum() | |
and len(string[i + 1 : i + 3]) == 2 | |
): | |
i += 3 | |
else: | |
return False | |
return True | |
# All characters must already be non-escaping or valid percent-encoded | |
for index, char in enumerate(string): | |
if char not in NON_ESCAPED_CHARS and not PERCENT_ENCODED_REGEX.match( | |
string[index : index + 3] | |
): | |
return False | |
return True |
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.
Thanks for review! I have applied the suggestion.
Add parsing symbol '%s' test rewrite fn::_urlparse::is_safe
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.
Thanks, I think it deserves a note in changelog.
Hi @T-256, |
Yes, if it is invalid percent-encoded. |
when can we merge this changes? @tomchristie |
Hello, could you look at if this PR fixes the cases of bad I think the change in this PR (to only encode |
Thanks. I think this is superseeded by #3187. |
I tried the same on http 0.27.0, still having the same issue. |
Fix httpx is not encoding with symbol '%s' (#3140)
Add url parsing test
Summary
Checklist