Skip to content
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

Accepting only ASCII characters left from TLD. #159

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tests/unit/test_find_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
@pytest.mark.parametrize(
"text, expected",
[
("%sexample.com" % chr(8231), ["example.com"]),
("some%sdomain.example.com" % chr(8231), ["domain.example.com"]),
("Let's have URL http://janlipovsky.cz", ["http://janlipovsky.cz"]),
("Let's have text without URLs.", []),
("Dot after TLD: http://janlipovsky.cz.", ["http://janlipovsky.cz"]),
Expand Down Expand Up @@ -57,7 +59,7 @@
"<script src='//www.example.com/somejsfile.js'>",
["www.example.com/somejsfile.js"],
),
("bad.email @address.net>", ['bad.email']),
("bad.email @address.net>", ["bad.email"]),
('[[ "$(giturl)" =~ ^https://gitlab.com ]] echo "found" || echo "didnt', []),
],
)
Expand Down
7 changes: 6 additions & 1 deletion urlextract/urlextract_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,12 @@ def _complete_url(
and text[start_pos - 1] in self._stop_chars_left_from_schema
):
left_ok = False
if left_ok and text[start_pos - 1] not in self._stop_chars_left:
if (
left_ok
and text[start_pos - 1] not in self._stop_chars_left
# Allow only ASCII characters in authority and schema
and ord(text[start_pos - 1]) <= 127
):
start_pos -= 1
else:
left_ok = False
Expand Down
Loading