Show More
@@ -28,7 +28,6 b' import os' | |||||
28 | import lxml |
|
28 | import lxml | |
29 | import logging |
|
29 | import logging | |
30 | import urlparse |
|
30 | import urlparse | |
31 | import urllib |
|
|||
32 |
|
31 | |||
33 | from mako.lookup import TemplateLookup |
|
32 | from mako.lookup import TemplateLookup | |
34 | from mako.template import Template as MakoTemplate |
|
33 | from mako.template import Template as MakoTemplate | |
@@ -48,7 +47,14 b" DEFAULT_COMMENTS_RENDERER = 'rst'" | |||||
48 |
|
47 | |||
49 |
|
48 | |||
50 | def relative_links(html_source, server_path): |
|
49 | def relative_links(html_source, server_path): | |
|
50 | if not html_source: | |||
|
51 | return html_source | |||
|
52 | ||||
|
53 | try: | |||
51 | doc = lxml.html.fromstring(html_source) |
|
54 | doc = lxml.html.fromstring(html_source) | |
|
55 | except Exception: | |||
|
56 | return html_source | |||
|
57 | ||||
52 | for el in doc.cssselect('img, video'): |
|
58 | for el in doc.cssselect('img, video'): | |
53 | src = el.attrib['src'] |
|
59 | src = el.attrib['src'] | |
54 | if src: |
|
60 | if src: | |
@@ -86,7 +92,7 b' def relative_path(path, request_path, is' | |||||
86 | path = safe_unicode(path) |
|
92 | path = safe_unicode(path) | |
87 | request_path = safe_unicode(request_path) |
|
93 | request_path = safe_unicode(request_path) | |
88 |
|
94 | |||
89 | if path.startswith((u'data:', u'#', u':')): |
|
95 | if path.startswith((u'data:', u'javascript:', u'#', u':')): | |
90 | # skip data, anchor, invalid links |
|
96 | # skip data, anchor, invalid links | |
91 | return path |
|
97 | return path | |
92 |
|
98 |
General Comments 0
You need to be logged in to leave comments.
Login now