• Deimos's avatar
    Replace bleach.linkify with cmark-gfm autolink · f1d2e0ae
    Deimos authored
    Yet another issue with Bleach 3.0's linkification: when used via the
    filter as part of sanitization (which is necessary right now due to
    *another* issue where it escapes valid HTML tags), it doesn't properly
    linkify urls that contain an ampersand.
    
    As a (temporary?) workaround, this stops using Bleach's linkification
    entirely and switches to cmark-gfm's "autolink" extension. These aren't
    perfectly equivalent, and the switch results in two other issues that I
    consider more minor than links including ampersands not working:
    
    - autolink will initially create links for ftp:// urls and email
      addresses. The final sanitization will remove these links due to the
      protocol whitelist, but it will leave behind a bare <a> tag. So the
      text will *appear* linked but not actually link to anything. If I
      decide to stick with autolink, it should be pretty straightforward to
      fix this by stripping all bare <a> tags from the final HTML.
    - autolink doesn't create links for bare domains. For example, writing
      "example.com" won't result in a link, it's necessary to write
      "www.example.com" or include a protocol like "http://example.com".
    f1d2e0ae
cmark.py 1.98 KB