Carl Meyer  committed accdf69

prevent mark_safe from mangling Markup objects

  • Participants
  • Parent commits 57063ca
  • Branches default

Comments (0)

Files changed (3)

 tip (unreleased)
+- prevent mark_safe from mangling Markup objects.
 0.6.0 (2010.04.26)

File markitup/

 from django.conf import settings
 from django.db import models
-from django.utils.safestring import mark_safe
+from django.utils.safestring import mark_safe, SafeData
 from django.utils.functional import curry
 from django.core.exceptions import ImproperlyConfigured
 from markitup import widgets
 except AttributeError, e:
     raise ImproperlyConfigured("MARKITUP_FILTER setting is required")
-class Markup(object):
+class Markup(SafeData):
     def __init__(self, instance, field_name, rendered_field_name):
         # instead of storing actual values store a reference to the instance
         # along with field names, this makes assignment possible

File tests/

 from django.core import serializers
 from django.forms.models import modelform_factory
 from django.db.models.fields import FieldDoesNotExist
+from django.utils.safestring import mark_safe
 from django import VERSION
 from django.contrib import admin
    = 'this should fail'
         self.assertRaises(AttributeError, _invalid_assignment)
+    def testMarkSafe(self):
+        """
+        Calling ``mark_safe`` on a ``Markup`` object should have no
+        effect, as the ``Markup`` object already handles marking the
+        rendered HTML safe on access.
+        """
+ = mark_safe(
+        self.assertEquals(, 'replace this text')
 #    def testOverrideFilter(self):