mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
Do not get MIME types base on URLs.
This commit is contained in:
parent
9d5cebb5ce
commit
9c9fc1ae2d
@ -902,7 +902,8 @@ def test_url_fetcher():
|
||||
if url == 'weasyprint-custom:foo/%C3%A9_%e9_pattern':
|
||||
return dict(string=pattern_png, mime_type='image/png')
|
||||
elif url == 'weasyprint-custom:foo/bar.css':
|
||||
return dict(string='body { background: url(é_%e9_pattern)')
|
||||
return dict(string='body { background: url(é_%e9_pattern)',
|
||||
mime_type='text/css')
|
||||
else:
|
||||
return default_url_fetcher(url)
|
||||
|
||||
@ -931,6 +932,6 @@ def test_url_fetcher():
|
||||
|
||||
def fetcher_2(url):
|
||||
assert url == 'weasyprint-custom:%C3%A9_%e9.css'
|
||||
return dict(string='')
|
||||
return dict(string='', mime_type='text/css')
|
||||
TestHTML(string='<link rel=stylesheet href="weasyprint-custom:'
|
||||
'é_%e9.css"><body>', url_fetcher=fetcher_2).render()
|
||||
|
@ -275,8 +275,5 @@ def fetch(url_fetcher, url):
|
||||
"""
|
||||
result = url_fetcher(url)
|
||||
result.setdefault('redirected_url', url)
|
||||
if 'mime_type' not in result:
|
||||
path = urlsplit(result['redirected_url']).path
|
||||
mime_type, _ = mimetypes.guess_type(path)
|
||||
result['mime_type'] = mime_type or 'application/octet-stream'
|
||||
result.setdefault('mime_type', None)
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user