xmlReader: join consecutive text data that had been cut by buffered parser
Fixes https://github.com/fonttools/fonttools/issues/2614
This commit is contained in:
parent
f7c1407703
commit
e8f8a6c40d
@ -148,6 +148,18 @@ class XMLReader(object):
|
||||
|
||||
def _characterDataHandler(self, data):
|
||||
if self.stackSize > 1:
|
||||
# parser parses in chunks, so we may get multiple calls
|
||||
# for the same text node; thus we need to append the data
|
||||
# to the last item in the content stack:
|
||||
# https://github.com/fonttools/fonttools/issues/2614
|
||||
if (
|
||||
data != "\n"
|
||||
and self.contentStack[-1]
|
||||
and isinstance(self.contentStack[-1][-1], str)
|
||||
and self.contentStack[-1][-1] != "\n"
|
||||
):
|
||||
self.contentStack[-1][-1] += data
|
||||
else:
|
||||
self.contentStack[-1].append(data)
|
||||
|
||||
def _endElementHandler(self, name):
|
||||
|
Loading…
x
Reference in New Issue
Block a user