Commits

Mike Orr committed d5f47f3

Fix HTML overescaping. Patch by Marius Gedminas.

  • Participants
  • Parent commits d592b6f

Comments (0)

Files changed (3)

 
 tip (development version)
 -------------------------
+* webhelpers.pylonslib:
+  - Fix HTML overescaping.  Patch by Marius Gedminas.
 
 
 1.0b1 (2009-11-20)

File tests/test_pylonslib_flash.py

 from nose.tools import eq_
 
 from webhelpers.pylonslib import Flash, Message
+from webhelpers.html import literal, escape
 
 class FakeSession(dict):
     def save(self):
         messages = flash.pop_messages()
         eq_(len(messages), 0)
 
+    def test_flash_literal(self):
+        MESSAGE1 = literal("Record <b>#775</b> deleted.")
+        MESSAGE2 = "Hope you like the <b>s."
+        flash = Flash()
+        flash(MESSAGE1)
+        flash(MESSAGE2)
+        messages = flash.pop_messages()
+        eq_(len(messages), 2)
+        eq_(escape(messages[0]), literal("Record <b>#775</b> deleted."))
+        eq_(escape(messages[1]), literal("Hope you like the &lt;b&gt;s."))
+
     def test_multiple_flashes(self):
         MESSAGE = "Hello, world!"
         DOOHICKEY_MESSAGE1 = "Added doohickey."

File webhelpers/pylonslib/__init__.py

 
     __unicode__ = __str__
 
+    @property
+    def __html__(self):
+        return getattr(self.message, '__html__')
+
 
 class Flash(object):
     """Accumulate a list of messages to show at the next page request.