[CMF-checkins] CVS: CMF/CMFDefault - utils.py:1.18.4.1

Yvo Schubbe schubbe@web.de
Fri, 21 Feb 2003 10:44:47 -0500


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv32372/CMFDefault

Modified Files:
      Tag: yuppie-collector108-branch
	utils.py 
Log Message:
- made StrippingParser closing empty tags (Collector #108)
- added scrubHTML test

=== CMF/CMFDefault/utils.py 1.18 => 1.18.4.1 ===
--- CMF/CMFDefault/utils.py:1.18	Thu Feb 13 03:36:31 2003
+++ CMF/CMFDefault/utils.py	Fri Feb 21 10:44:46 2003
@@ -234,10 +234,10 @@
 # These are the HTML tags that we will leave intact
 VALID_TAGS = { 'a'          : 1
              , 'b'          : 1
-             , 'base'       : 1
+             , 'base'       : 0
              , 'blockquote' : 1
              , 'body'       : 1
-             , 'br'         : 1
+             , 'br'         : 0
              , 'caption'    : 1
              , 'cite'       : 1
              , 'code'       : 1
@@ -253,14 +253,14 @@
              , 'h5'         : 1
              , 'h6'         : 1
              , 'head'       : 1
-             , 'hr'         : 1
+             , 'hr'         : 0
              , 'html'       : 1
              , 'i'          : 1
-             , 'img'        : 1
+             , 'img'        : 0
              , 'kbd'        : 1
              , 'li'         : 1
            # , 'link'       : 1 type="script" hoses us
-             , 'meta'       : 1
+             , 'meta'       : 0
              , 'ol'         : 1
              , 'p'          : 1
              , 'pre'        : 1
@@ -321,7 +321,7 @@
 
         """ Delete all tags except for legal ones.
         """
-        if VALID_TAGS.get( tag ):
+        if VALID_TAGS.has_key(tag):
 
             self.result = self.result + '<' + tag
 
@@ -336,7 +336,10 @@
                 self.result = '%s %s="%s"' % (self.result, k, v)
 
             endTag = '</%s>' % tag
-            self.result = self.result + '>'
+            if VALID_TAGS.get(tag):
+                self.result = self.result + '>'
+            else:
+                self.result = self.result + ' />'
 
         elif NASTY_TAGS.get( tag ):
             raise IllegalHTML, 'Dynamic tag "%s" not allowed.' % tag