diff options
author | Guido van Rossum <guido@python.org> | 1998-12-07 21:59:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-12-07 21:59:56 (GMT) |
commit | f484a3366b2e0e40b0577d652407f9b84a0ec208 (patch) | |
tree | 2a9c30903e231f9ae4737dddafc4eea8ee89dc0d | |
parent | 926f7b66153a74ae20b666be137ddfb87e375c2e (diff) | |
download | cpython-f484a3366b2e0e40b0577d652407f9b84a0ec208.zip cpython-f484a3366b2e0e40b0577d652407f9b84a0ec208.tar.gz cpython-f484a3366b2e0e40b0577d652407f9b84a0ec208.tar.bz2 |
Sjoerd writes:
When literal mode is entered it should exit automatically when the
matching close tag of the last unclosed open tag is encountered. This
patch fixes this.
-rw-r--r-- | Doc/lib/libxmllib.tex | 3 | ||||
-rw-r--r-- | Lib/xmllib.py | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/Doc/lib/libxmllib.tex b/Doc/lib/libxmllib.tex index d8aa3ed..7a7c85d 100644 --- a/Doc/lib/libxmllib.tex +++ b/Doc/lib/libxmllib.tex @@ -27,7 +27,8 @@ Stop processing tags. Treat all following input as literal input \end{methoddesc} \begin{methoddesc}{setliteral}{} -Enter literal mode (CDATA mode). +Enter literal mode (CDATA mode). This mode is automatically exited +when the close tag matching the last unclosed open tag is encountered. \end{methoddesc} \begin{methoddesc}{feed}{data} diff --git a/Lib/xmllib.py b/Lib/xmllib.py index 06dc373..4e62ae5 100644 --- a/Lib/xmllib.py +++ b/Lib/xmllib.py @@ -205,7 +205,6 @@ class XMLParser: if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k - self.literal = 0 continue if commentopen.match(rawdata, i): if self.literal: @@ -503,11 +502,19 @@ class XMLParser: return -1 res = tagfind.match(rawdata, i+2) if res is None: + if self.literal: + self.handle_data(rawdata[i]) + return i+1 self.syntax_error('no name specified in end tag') tag = '' k = i+2 else: tag = res.group(0) + if self.literal: + if not self.stack or tag != self.stack[-1]: + self.handle_data(rawdata[i]) + return i+1 + self.literal = 0 k = res.end(0) if endbracket.match(rawdata, k) is None: self.syntax_error('garbage in end tag') |