Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<h1>Hello</h1>
<h2>World</h2>
<h3>Test</h3>
<a href="#">Link</a>
"""
p = Premailer(
html,
strip_important=False
)
assert_raises(
ExternalNotFoundError,
p.transform,
)
if not os.path.isabs(stylefile):
stylefile = os.path.abspath(
os.path.join(self.base_path or '', stylefile)
)
elif os.path.isabs(stylefile): # <--- This is the if branch we added
stylefile = os.path.abspath(
os.path.join(self.base_path or '', stylefile[1:])
)
if os.path.exists(stylefile):
with codecs.open(stylefile, encoding='utf-8') as f:
css_body = f.read()
elif self.base_url:
url = urljoin(self.base_url, url)
return self._load_external(url)
else:
raise ExternalNotFoundError(stylefile)
return css_body
if url.startswith("http://") or url.startswith("https://"):
css_body = self._load_external_url(url)
else:
stylefile = url
if not os.path.isabs(stylefile):
stylefile = os.path.abspath(
os.path.join(self.base_path or "", stylefile)
)
if os.path.exists(stylefile):
with codecs.open(stylefile, encoding="utf-8") as f:
css_body = f.read()
elif self.base_url:
url = urljoin(self.base_url, url)
return self._load_external(url)
else:
raise ExternalNotFoundError(stylefile)
return css_body
if url.startswith('http://') or url.startswith('https://'):
content = self._load_external_url(url)
else:
content = None
if self.local_loader:
try:
content = self.local_loader[url]
except FileNotFound:
content = None
if content is None:
if self.base_url:
return self._load_external(urlparse.urljoin(self.base_url, url))
else:
raise ExternalNotFoundError(url)
return content
if url.startswith('http://') or url.startswith('https://'):
css_body = self._load_external_url(url)
else:
stylefile = url
if not os.path.isabs(stylefile):
stylefile = os.path.abspath(
os.path.join(self.base_path or '', stylefile)
)
if os.path.exists(stylefile):
with codecs.open(stylefile, encoding='utf-8') as f:
css_body = f.read()
elif self.base_url:
url = urljoin(self.base_url, url)
return self._load_external(url)
else:
raise ExternalNotFoundError(stylefile)
return css_body
please revert your last change, hope that helps :)
"""
class LiveJSONDecodeError(LiveBaseError):
MSG = 'Your json file is invalid:'
def live_message(self):
msg = '\n{}\n{}\n{}: line {} column {} char({})\n'
return msg.format(self.src_path, self.MSG, self.e.msg, self.e.lineno,
self.e.colno, self.e.pos)
ERRORS = {
AttributeError: LiveAttributeError,
ExternalNotFoundError: LiveExternalNotFoundError,
TemplateNotFound: LiveTemplateNotFound,
TemplateSyntaxError: LiveTemplateSyntaxError,
TypeError: LiveTypeError,
UndefinedError: LiveUndefinedError,
UnicodeDecodeError: LiveUnicodeDecodeError,
UnicodeEncodeError: LiveUnicodeEncodeError,
ValueError: LiveValueError,
}
if six.PY3:
try:
from json.decoder import JSONDecodeError
ERRORS[JSONDecodeError] = LiveJSONDecodeError
except ImportError:
pass