[ZPT] CVS: Packages/TAL - HTMLParser.py:1.9

guido@digicool.com guido@digicool.com
Sat, 24 Mar 2001 14:33:14 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv17822

Modified Files:
	HTMLParser.py 
Log Message:
Fix the test for properly closed endtags.



--- Updated File HTMLParser.py in package Packages/TAL --
--- HTMLParser.py	2001/03/22 17:54:13	1.8
+++ HTMLParser.py	2001/03/24 19:33:14	1.9
@@ -35,6 +35,7 @@
 locatestarttagend = re.compile("('[^']*'|\"[^\"]*\"|[^'\">]+)*/?>")
 endstarttag = re.compile(r"\s*/?>")
 endendtag = re.compile('>')
+endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
 
 declname = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*')
 declstringlit = re.compile(r'(\'[^\']*\'|"[^"]*")\s*')
@@ -309,9 +310,11 @@
         if not match:
             return -1
         j = match.end()
-        tag = string.lower(string.strip(rawdata[i+2:j-1]))
-        if not tag:
-            raise HTMLParseError("empty start tag", self.getpos())
+        match = endtagfind.match(rawdata, i) # </ + tag + >
+        if not match:
+            raise HTMLParseError("bad end tag: %s" % `rawdata[i:j]`,
+                                 self.getpos())
+        tag = match.group(1)
         self.handle_endtag(tag)
         return j