=== added directory 'tests/regressiontests/utils'
=== added file 'tests/regressiontests/utils/__init__.py'
=== added file 'tests/regressiontests/utils/models.py'
--- tests/regressiontests/utils/models.py	1970-01-01 00:00:00 +0000
+++ tests/regressiontests/utils/models.py	2007-06-04 01:50:54 +0000
@@ -0,0 +1,1 @@
+# pointless, but needed due to the runner being special

=== added file 'tests/regressiontests/utils/tests.py'
--- tests/regressiontests/utils/tests.py	1970-01-01 00:00:00 +0000
+++ tests/regressiontests/utils/tests.py	2007-06-04 02:24:52 +0000
@@ -0,0 +1,56 @@
+"""
+tests for django.utils.html
+"""
+
+from unittest import TestCase
+from django.utils import html
+
+
+class TestUtils(TestCase):
+
+    def test_escape(self):
+        for token, replacement in (('&','&amp;'), ('<', '&lt;'), ('>', '&gt;'), ('"', '&quot;'), ("'", '&#39;')):
+            for pattern in ("%s", "asdf%sfdsa", "%s", "%s1", "1%sb"):
+                self.assertEqual(html.escape(pattern % token), pattern % replacement)
+            self.assertEqual(html.escape(token *2), replacement * 2)
+        # verify it doesn't double replace &
+        self.assertEqual(html.escape('<&'), '&lt;&amp;')
+
+    def test_linebreaks(self):
+        text = "para1\nsub1\nsub2\rsub3\n\npara2\r\n\r\npara3\r\rpara4\rsub1"
+        self.assertEqual(html.linebreaks(text),
+            "<p>para1<br />sub1<br />sub2<br />sub3</p>\n\n<p>para2</p>\n\n<p>para3</p>\n\n<p>para4<br />sub1</p>")
+
+    def test_strip_tags(self):
+        for x, y in (('<adf>a', 'a'), ('</adf>a', 'a'),
+            ('<asdf><asdf>e', 'e'), ('<f', '<f'), ('</fe', '</fe'),
+            ('<x>b<y>', 'b')):
+            self.assertEqual(html.strip_tags(x), y)
+
+    def test_strip_spaces_between_tags(self):
+        f = html.strip_spaces_between_tags
+        for data in (' <adf>', '<adf> ', ' </adf> ',
+            ('<d> </d>', '<d></d>'), ' <f> x</f>'):
+            if isinstance(data, basestring):
+                data = [data, data]
+            self.assertEqual(f(data[0]), data[1])
+
+    def test_strip_entities(self):
+        f = html.strip_entities
+        self.assertEqual(f("&"), "&")
+        self.assertEqual(f("&a"), "&a")
+        self.assertEqual(f("&a"), "&a")
+        self.assertEqual(f("a&#a"), "a&#a")
+        for x in ("#1", "#12", "a", "fdasdfasdfasdf"):
+            entity = "&%s;" % x
+            self.assertEqual(f("asdf %s " % entity), "asdf  ")
+            self.assertEqual(f("%s%s" % (entity, entity)), "")
+            self.assertEqual(f("&%s%s" % (entity, entity)), "&")
+            self.assertEqual(f("%s3" % entity), "3")
+
+    def test_fix_ampersands(self):
+        f = html.fix_ampersands
+        for x in ("a&#1;", "b", "&a;", "&amp; &x; ", "asdf"):
+            self.assertEqual(f(x), x)
+            self.assertEqual(f("&" + x), "&amp;" + x)
+            self.assertEqual(f("&%s&" % x), "&amp;" + x + "&amp;")

=== modified file 'django/utils/html.py'
--- django/utils/html.py	2007-04-05 14:52:33 +0000
+++ django/utils/html.py	2007-06-04 02:20:03 +0000
@@ -45,7 +45,7 @@
 
 def strip_entities(value):
     "Returns the given HTML with all entities (&something;) stripped"
-    return re.sub(r'&(?:\w+|#\d);', '', value)
+    return re.sub(r'&(?:\w+|#\d+);', '', value)
 
 def fix_ampersands(value):
     "Returns the given HTML with all unencoded ampersands encoded correctly"

