functions.py 341 B

1234567891011121314151617
  1. import re
  2. unsharer = re.compile(r"(\?share=|#).+$", flags=re.IGNORECASE)
  3. def sanitizeUrl(url):
  4. global unsharer
  5. ret = re.sub(unsharer, "", url)
  6. return ret
  7. def sanitizeSelector(s):
  8. s = s.replace(">a", "> a")
  9. if re.match(r'=\w+\]', s) is None:
  10. return s
  11. ret = re.sub(r"=(\w+)]", r'="\1"]', s)
  12. return ret