summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-04-17 11:01:51 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2014-04-17 11:05:05 +0200
commit188802ce86879aafc3472619ce82ae1768210d83 (patch)
tree3696cfb417d35c31754aa159e5ffa35f8861a6c9
parent497d9b67793ad9ca09d597c27d1196a94f57ddc4 (diff)
downloadmarkupsafe-188802ce86879aafc3472619ce82ae1768210d83.tar.gz
Fixed missing escaping for keyword arguments.
-rw-r--r--markupsafe/__init__.py4
-rw-r--r--markupsafe/_compat.py2
-rw-r--r--markupsafe/tests.py9
3 files changed, 13 insertions, 2 deletions
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py
index 25f00d3..5c5af40 100644
--- a/markupsafe/__init__.py
+++ b/markupsafe/__init__.py
@@ -10,7 +10,7 @@
"""
import re
from markupsafe._compat import text_type, string_types, int_types, \
- unichr, PY2
+ unichr, iteritems, PY2
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
@@ -168,7 +168,7 @@ class Markup(text_type):
orig = getattr(text_type, name)
def func(self, *args, **kwargs):
args = _escape_argspec(list(args), enumerate(args), self.escape)
- #_escape_argspec(kwargs, kwargs.iteritems(), None)
+ _escape_argspec(kwargs, iteritems(kwargs), self.escape)
return self.__class__(orig(self, *args, **kwargs))
func.__name__ = orig.__name__
func.__doc__ = orig.__doc__
diff --git a/markupsafe/_compat.py b/markupsafe/_compat.py
index 29e4a3d..62e5632 100644
--- a/markupsafe/_compat.py
+++ b/markupsafe/_compat.py
@@ -17,8 +17,10 @@ if not PY2:
string_types = (str,)
unichr = chr
int_types = (int,)
+ iteritems = lambda x: iter(x.items())
else:
text_type = unicode
string_types = (str, unicode)
unichr = unichr
int_types = (int, long)
+ iteritems = lambda x: x.iteritems()
diff --git a/markupsafe/tests.py b/markupsafe/tests.py
index b34cc6e..145fafb 100644
--- a/markupsafe/tests.py
+++ b/markupsafe/tests.py
@@ -65,6 +65,15 @@ class MarkupTestCase(unittest.TestCase):
assert Markup("<em>Foo &amp; Bar</em>").striptags() == "Foo & Bar"
assert Markup("&lt;test&gt;").unescape() == "<test>"
+ def test_formatting(self):
+ for actual, expected in (
+ (Markup('%i') % 3.14, '3'),
+ (Markup('%.2f') % 3.14159, '3.14'),
+ (Markup('%s %s %s') % ('<', 123, '>'), '&lt; 123 &gt;'),
+ (Markup('<em>{awesome}</em>').format(awesome='<awesome>'),
+ '<em>&lt;awesome&gt;</em>')):
+ assert actual == expected, "%r should be %r!" % (actual, expected)
+
def test_all_set(self):
import markupsafe as markup
for item in markup.__all__: