-
-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2041 from edugonza/main
fixes #2040 Wrapped urlsplit call in a try-except block
- Loading branch information
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Test URLs.""" | ||
|
||
import re | ||
|
||
import pytest | ||
|
||
from .testing_utils import FakeHTML, capture_logs, resource_path | ||
|
||
|
||
@pytest.mark.parametrize('url, base_url', ( | ||
('https://weasyprint.org]', resource_path('<inline HTML>')), | ||
('https://weasyprint.org]', 'https://weasyprint.org]'), | ||
('https://weasyprint.org/', 'https://weasyprint.org]'), | ||
)) | ||
def test_malformed_url_link(url, base_url): | ||
"""Test malformed URLs.""" | ||
with capture_logs() as logs: | ||
pdf = FakeHTML( | ||
string=f'<p><a href="{url}">My Link</a></p>', | ||
base_url=base_url).write_pdf() | ||
|
||
assert len(logs) == 1 | ||
assert "Malformed" in logs[0] | ||
assert "]" in logs[0] | ||
|
||
uris = re.findall(b'/URI \\((.*)\\)', pdf) | ||
types = re.findall(b'/S (/\\w*)', pdf) | ||
subtypes = re.findall(b'/Subtype (/\\w*)', pdf) | ||
|
||
assert uris.pop(0) == url.encode() | ||
assert subtypes.pop(0) == b'/Link' | ||
assert types.pop(0) == b'/URI' |
This file contains 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