Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
)
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