Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save(self, filename, obj):
files.save_obj(obj, self.id, filename)
def absurl(path):
return files.tnurl(path)
title_to_use = self.title if hasattr(self,'title') and self.title else self.url
if preferred_image:
output = "%s> [ ![%s](%s \"%s\") ](%s \"%s\") <br>\n" % (output, title_to_use_bracket_safe, absurl(preferred_image), title_to_use_quote_safe, files.lurl(self.url), title_to_use_quote_safe)
output = "%s> [%s](%s \"%s\") <br>\n" % (output, title_to_use_bracket_safe, files.lurl(self.url), title_to_use_quote_safe)
if self.summary:
about = "%s... %s" % (self.summary, self.description)
about = re.sub('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', '', about)
about = re.sub(r'[\r\n]*', '', about)
output = "%s> %s<br>\n" % (output, about[:500])
return output
else:
if not text_only:
#[ ![Image](/images/image.jpg "Image title") ](http://google.com "Google")
if preferred_image:
return "[ ![%s](%s \"%s\") ](%s \"%s\")" % (title_to_use_bracket_safe, absurl(preferred_image), title_to_use_quote_safe, files.lurl(self.url), title_to_use_quote_safe)
# fallback to text only
return "[%s](%s \"%s\")" % (title_to_use_bracket_safe, files.lurl(self.url), title_to_use_quote_safe)
# fallback
return ""
def file_load(self, filename):
return files.load_obj(self.id, filename)