mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix #2003: decode error under python2 (only) when `make linkcheck` is run
This commit is contained in:
@@ -15,6 +15,8 @@ Bugs fixed
|
||||
* #2171: Fix cannot linkcheck url with unicode
|
||||
* #2182: LaTeX: support image file names with more than 1 dots
|
||||
* #2189: Fix previous sibling link for first file in subdirectory uses last file, not intended previous from root toctree
|
||||
* #2003: Fix decode error under python2 (only) when ``make linkcheck`` is run
|
||||
|
||||
|
||||
|
||||
Release 1.3.3 (released Dec 2, 2015)
|
||||
|
||||
@@ -95,6 +95,17 @@ def check_anchor(f, hash):
|
||||
return parser.found
|
||||
|
||||
|
||||
def get_content_charset(f):
|
||||
content_type = f.headers.get('content-type')
|
||||
if content_type:
|
||||
params = (p.strip() for p in content_type.split(';')[1:])
|
||||
for param in params:
|
||||
if param.startswith('charset='):
|
||||
return param[8:]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class CheckExternalLinksBuilder(Builder):
|
||||
"""
|
||||
Checks for broken external links.
|
||||
@@ -165,6 +176,8 @@ class CheckExternalLinksBuilder(Builder):
|
||||
encoding = 'utf-8'
|
||||
if hasattr(f.headers, 'get_content_charset'):
|
||||
encoding = f.headers.get_content_charset() or encoding
|
||||
else:
|
||||
encoding = get_content_charset(f) or encoding
|
||||
found = check_anchor(TextIOWrapper(f, encoding), unquote(hash))
|
||||
f.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user