Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Specify an html tokenizer when calling linkify.

This will only work with bleach v1.1.4 and up, and prevents unknown tags from
being unfairly escaped during the linkify step (which causes problems).
  • Loading branch information...
commit 64daa0999004c738e4788047b363945355e2dca5 1 parent 3d0e4b2
Mike Cooper authored

Showing 2 changed files with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 1  setup.py
  2. +3 1 wikimarkup/parser.py
2  setup.py
@@ -13,6 +13,6 @@
13 13 url='http://www.github.com/dcramer/py-wikimarkup/',
14 14 zip_safe=False,
15 15 include_package_data=True,
16   - install_requires=['bleach'],
  16 + install_requires=['bleach>=1.1.4'],
17 17 package_data = { '': ['README.rst'] },
18 18 )
4 wikimarkup/parser.py
@@ -23,6 +23,8 @@
23 23
24 24 import bleach
25 25
  26 +from html5lib.tokenizer import HTMLTokenizer
  27 +
26 28 # a few patterns we use later
27 29
28 30 MW_COLON_STATE_TEXT = 0
@@ -1711,7 +1713,7 @@ def parse(self, text, show_toc=True, tags=ALLOWED_TAGS,
1711 1713 if utf8:
1712 1714 text.encode("utf-8")
1713 1715 # Pass output through bleach and linkify
1714   - text = bleach.linkify(text, nofollow=nofollow)
  1716 + text = bleach.linkify(text, nofollow=nofollow, tokenizer=HTMLTokenizer)
1715 1717 return bleach.clean(text, tags=self.tags, attributes=attributes,
1716 1718 styles=styles, strip_comments=False)
1717 1719

0 comments on commit 64daa09

Please sign in to comment.
Something went wrong with that request. Please try again.