##// END OF EJS Templates
makrup-renderer: fix some cases which could cause lxml errors, skip js flags
marcink -
r1529:3683d343 default
parent child Browse files
Show More
@@ -28,7 +28,6 b' import os'
28 28 import lxml
29 29 import logging
30 30 import urlparse
31 import urllib
32 31
33 32 from mako.lookup import TemplateLookup
34 33 from mako.template import Template as MakoTemplate
@@ -48,7 +47,14 b" DEFAULT_COMMENTS_RENDERER = 'rst'"
48 47
49 48
50 49 def relative_links(html_source, server_path):
50 if not html_source:
51 return html_source
52
53 try:
51 54 doc = lxml.html.fromstring(html_source)
55 except Exception:
56 return html_source
57
52 58 for el in doc.cssselect('img, video'):
53 59 src = el.attrib['src']
54 60 if src:
@@ -86,7 +92,7 b' def relative_path(path, request_path, is'
86 92 path = safe_unicode(path)
87 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 96 # skip data, anchor, invalid links
91 97 return path
92 98
General Comments 0
You need to be logged in to leave comments. Login now