FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Check whether an EncodedURL can be decoded before giving it back by exarkun · Pull Request #178 · python-hyper/hyperlink · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ini  (1) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 8 additions & 4 deletions src/hyperlink/hypothesis.py
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
Expand Up @@ -31,7 +31,7 @@

from . import DecodedURL, EncodedURL

from hypothesis import assume
from hypothesis import reject
from hypothesis.strategies import (
composite,
integers,
Expand Down Expand Up @@ -137,7 +137,7 @@ def idna_text(draw, min_size=1, max_size=None):
try:
idna_encode(result)
except IDNAError:
assume(False)
reject()

return result

Expand Down Expand Up @@ -198,7 +198,7 @@ def hostname_labels(draw, allow_idn=True):
try:
check_label(label)
except UnicodeError: # pragma: no cover (not always drawn)
assume(False)
reject()

return label

Expand Down Expand Up @@ -318,4 +318,8 @@ def decoded_urls(draw):
Call the L{EncodedURL.to_uri} method on each URL to get an HTTP
protocol-friendly URI.
"""
return DecodedURL(draw(encoded_urls()))
encoded_url = draw(encoded_urls())
try:
return DecodedURL(encoded_url)
except UnicodeDecodeError:
reject()
8 changes: 8 additions & 0 deletions tox.ini
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
Expand Up @@ -93,7 +93,15 @@ basepython = {[default]basepython}
skip_install = True

deps =
# Pin black and all of its dependencies so an incompatible release of one
# of them doesn't break this environment.
appdirs==1.4.4
black==21.7b0
click==7.1.2
mypy-extensions==0.4.3
pathspec==0.9.0
regex==2022.8.17
tomli==1.2.3

setenv =
BLACK_LINT_ARGS=--check
Expand Down

Back | FazBrowse Home | New Git URL