mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
parent
186c6550ed
commit
40f4e9af4c
@ -799,7 +799,8 @@ uses_relative.append('weasyprint-custom')
|
||||
|
||||
@assert_no_logs
|
||||
def test_url_fetcher():
|
||||
with open(resource_filename('pattern.png'), 'rb') as pattern_fd:
|
||||
filename = resource_filename('pattern.png')
|
||||
with open(filename, 'rb') as pattern_fd:
|
||||
pattern_png = pattern_fd.read()
|
||||
|
||||
def fetcher(url):
|
||||
@ -822,6 +823,8 @@ def test_url_fetcher():
|
||||
check_png_pattern(html.write_png(stylesheets=[css]), blank=blank)
|
||||
|
||||
test('<body><img src="pattern.png">') # Test a "normal" URL
|
||||
test('<body><img src="%s">' % Path(filename).as_uri())
|
||||
test('<body><img src="%s?ignored">' % Path(filename).as_uri())
|
||||
test('<body><img src="weasyprint-custom:foo/é_%e9_pattern">')
|
||||
test('<body style="background: url(weasyprint-custom:foo/é_%e9_pattern)">')
|
||||
test('<body><li style="list-style: inside '
|
||||
|
@ -232,6 +232,10 @@ def default_url_fetcher(url, timeout=10):
|
||||
|
||||
"""
|
||||
if UNICODE_SCHEME_RE.match(url):
|
||||
# See https://bugs.python.org/issue34702
|
||||
if url.startswith('file://'):
|
||||
url = url.split('?')[0]
|
||||
|
||||
url = iri_to_uri(url)
|
||||
response = urlopen(Request(url, headers=HTTP_HEADERS), timeout=timeout)
|
||||
response_info = response.info()
|
||||
|
Loading…
Reference in New Issue
Block a user