Commits

Ian Lewis committed b01086a

Added tests for css sanitization of style tags

  • Participants
  • Parent commits b17ba98

Comments (0)

Files changed (1)

lifestream/tests/util_tests.py

             u'<b>Ian&apos;s Homepage</b>',
         ),
         (
-            u'"I CaN HaZ SoMe <TeXt"', u'&quot;I CaN HaZ SoMe &lt;TeXt&gt;&quot;',
+            u'"I CaN HaZ SoMe <TeXt"',
+            u'&quot;I CaN HaZ SoMe &lt;TeXt&gt;&quot;',
         ),
     )
+
+class CSSSanitizationTest(HTMLSanitizationTest):
+    valid_tags = {
+        'div': ('style',),
+        'span': ('style',),
+    }
+    valid_styles = (
+        "color",
+        "font-weight",
+    )
+    test_html = (
+        (
+            u'<span style="color:#FFF;position:absolute;">My Homepage</span>', 
+            u'<span style="color:#FFF;">My Homepage</span>', 
+        ),
+        (
+            u'<span style="color:#FFF;position:absolute;font-weight:bold;">My Homepage</span>', 
+            u'<span style="color:#FFF;font-weight:bold;">My Homepage</span>', 
+        ),
+        (
+            u'<span style="color:#FFF;position:absolute   ">My Homepage</span>', 
+            u'<span style="color:#FFF;">My Homepage</span>', 
+        ),
+        (
+            u'<span style="  color:#FFF;  position:absolute;\tfont-weight:bold  ">My Homepage</span>', 
+            u'<span style="color:#FFF;font-weight:bold;">My Homepage</span>', 
+        ),
+        (
+            u'<span style="  color:#FFF;  position:absolute;\tfont-weight:bold;  aaaaa">My Homepage</span>', 
+            u'<span style="color:#FFF;font-weight:bold;">My Homepage</span>', 
+        ),
+    )