Mercurial > genshi > mirror
diff genshi/filters/html.py @ 933:1e8c33345e52 trunk
Merge r1141 from py3k:
add support for python 3 to genshi.filters:
* minor changes to track encoding=None API change in core genshi modules.
* renamed genshi/filters/tests/html.py to test_html.py to avoid clashes with Python 3 top-level html module when running tests subset.
* did not rename genshi/filters/html.py.
* i18n filters:
* ugettext and friends are gone in Python 3 (and only gettext and friends exist and they now handle unicode)
* Some \ line continuations inside doctests confused 2to3 and so were removed them.
* Testing picked up a problem (already present in trunk) where Translator.__call__ could end up defining gettext as an endlessly recursive function. Noted with a TODO.
author | hodgestar |
---|---|
date | Fri, 18 Mar 2011 09:11:53 +0000 |
parents | 19750e09fab1 |
children | 8bc6f32fdd45 |
line wrap: on
line diff
--- a/genshi/filters/html.py +++ b/genshi/filters/html.py @@ -32,7 +32,7 @@ >>> from genshi.input import HTML >>> html = HTML('''<form> ... <p><input type="text" name="foo" /></p> - ... </form>''') + ... </form>''', encoding='utf-8') >>> filler = HTMLFormFiller(data={'foo': 'bar'}) >>> print(html | filler) <form> @@ -199,7 +199,7 @@ from the stream. >>> from genshi import HTML - >>> html = HTML('<div><script>alert(document.cookie)</script></div>') + >>> html = HTML('<div><script>alert(document.cookie)</script></div>', encoding='utf-8') >>> print(html | HTMLSanitizer()) <div/> @@ -207,7 +207,7 @@ is instantiated. For example, to allow inline ``style`` attributes, the following instantation would work: - >>> html = HTML('<div style="background: #000"></div>') + >>> html = HTML('<div style="background: #000"></div>', encoding='utf-8') >>> sanitizer = HTMLSanitizer(safe_attrs=HTMLSanitizer.SAFE_ATTRS | set(['style'])) >>> print(html | sanitizer) <div style="background: #000"/> @@ -215,7 +215,7 @@ Note that even in this case, the filter *does* attempt to remove dangerous constructs from style attributes: - >>> html = HTML('<div style="background: url(javascript:void); color: #000"></div>') + >>> html = HTML('<div style="background: url(javascript:void); color: #000"></div>', encoding='utf-8') >>> print(html | sanitizer) <div style="color: #000"/>