markup-renderer: use safe fetching of attributes to prevent from errors on malformed html.

This commit is contained in:
Marcin Kuzminski 2017-06-27 15:44:49 +02:00
parent 2500061c51
commit 002332dbc2

View file

@ -83,12 +83,12 @@ def relative_links(html_source, server_path):
return html_source
for el in doc.cssselect('img, video'):
src = el.attrib['src']
src = el.attrib.get('src')
if src:
el.attrib['src'] = relative_path(src, server_path)
for el in doc.cssselect('a:not(.gfm)'):
src = el.attrib['href']
src = el.attrib.get('href')
if src:
el.attrib['href'] = relative_path(src, server_path)