summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>2000-07-04 14:53:12 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>2000-07-04 14:53:12 (GMT)
commit5baaf66525aa7b3a61d2fec14b945539cd36d689 (patch)
tree04a6065aeaf936b7c990afe9aa1e804bab624809 /Lib
parent8bcfb8a5e09f15f6bf8dfb9f282192d03eac4fd8 (diff)
downloadcpython-5baaf66525aa7b3a61d2fec14b945539cd36d689.zip
cpython-5baaf66525aa7b3a61d2fec14b945539cd36d689.tar.gz
cpython-5baaf66525aa7b3a61d2fec14b945539cd36d689.tar.bz2
2 fixes plus one extension:
- Actually count the linefeeds in a the CDATA content. - Don't call the endtag handler for an unmatched endtag (this makes the base class simpler since it doesn't have to deal with unopened endtags). - If the __init__ method is called with keyword argument translate_attribute_references=0, don't attempt to translate character and entity references in attribute values.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/xmllib.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/xmllib.py b/Lib/xmllib.py
index 37f3f91..024e7f8 100644
--- a/Lib/xmllib.py
+++ b/Lib/xmllib.py
@@ -90,6 +90,7 @@ class XMLParser:
__accept_missing_endtag_name = 0
__map_case = 0
__accept_utf8 = 0
+ __translate_attribute_references = 1
# Interface -- initialize and reset this instance
def __init__(self, **kw):
@@ -102,6 +103,8 @@ class XMLParser:
self.__map_case = kw['map_case']
if kw.has_key('accept_utf8'):
self.__accept_utf8 = kw['accept_utf8']
+ if kw.has_key('translate_attribute_references'):
+ self.__translate_attribute_references = kw['translate_attribute_references']
self.reset()
def __fixelements(self):
@@ -171,6 +174,8 @@ class XMLParser:
# Interface -- translate references
def translate_references(self, data, all = 1):
+ if not self.__translate_attribute_references:
+ return data
i = 0
while 1:
res = amp.search(data, i)
@@ -277,7 +282,7 @@ class XMLParser:
if cdataopen.match(rawdata, i):
k = self.parse_cdata(i)
if k < 0: break
- self.lineno = self.lineno + string.count(rawdata[i:i], '\n')
+ self.lineno = self.lineno + string.count(rawdata[i:k], '\n')
i = k
continue
res = xmldecl.match(rawdata, i)
@@ -691,11 +696,6 @@ class XMLParser:
found = i
if found == -1:
self.syntax_error('unopened end tag')
- method = self.elements.get(tag, (None, None))[1]
- if method is not None:
- self.handle_endtag(tag, method)
- else:
- self.unknown_endtag(tag)
return
while len(self.stack) > found:
if found < len(self.stack) - 1: