aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2020-10-19 16:00:00 +0000
committerPatrice Clement <monsieurp@gentoo.org>2020-11-05 22:05:44 +0100
commit5480034ddf29a050671aa22effdd1cefb1a97f55 (patch)
tree52ec868177e815ff93cbcc936c211472fb9fe445 /src/py/xml-rewrite-2.py
parentxml-rewrite-2.py: add back os.chdir() function call. (diff)
downloadjavatoolkit-5480034ddf29a050671aa22effdd1cefb1a97f55.tar.gz
javatoolkit-5480034ddf29a050671aa22effdd1cefb1a97f55.tar.bz2
javatoolkit-5480034ddf29a050671aa22effdd1cefb1a97f55.zip
allow expanding external entities through SAX parser.
Python xml.sax module by default does not expand external entities since Python 3.6.7, 3.7.1 and 3.8.0: https://bugs.python.org/issue17239 3.6: https://github.com/python/cpython/commit/582d188e6e3487180891f1fc457a80dec8be26a8 3.7: https://github.com/python/cpython/commit/394e55a9279d17240ef6fe85d3b4ea3fe7b6dff5 3.8: https://github.com/python/cpython/commit/17b1d5d4e36aa57a9b25a0e694affbd1ee637e45 build.xml files may contain external entities resolving to other .xml files in given package. Closes: https://bugs.gentoo.org/698954 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
Diffstat (limited to 'src/py/xml-rewrite-2.py')
-rwxr-xr-xsrc/py/xml-rewrite-2.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/py/xml-rewrite-2.py b/src/py/xml-rewrite-2.py
index 4035119..ad0f12e 100755
--- a/src/py/xml-rewrite-2.py
+++ b/src/py/xml-rewrite-2.py
@@ -1,13 +1,17 @@
#!/usr/bin/env python3
-# Copyright 2004-2006 Gentoo Foundation
-# Distributed under the terms of the GNU General Public Licence v2
+# Copyright 2004-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
-import sys
import io
-from xml.sax.saxutils import quoteattr, escape
+import sys
+
from optparse import OptionParser, make_option
-from xml.sax.saxutils import XMLGenerator
+
+import xml.sax.handler
+from xml.sax.saxutils import XMLGenerator, escape, quoteattr
+
+import javatoolkit.xml.sax
def add_gentoo_classpath(document):
@@ -190,8 +194,7 @@ class SaxRewriter(XMLGenerator, StreamRewriterBase):
XMLGenerator.__init__(self, self.buffer, 'UTF-8')
def process(self, in_stream):
- from xml.sax import parse
- parse(in_stream, self)
+ javatoolkit.xml.sax.parse(in_stream, content_handler=self, features={xml.sax.handler.feature_external_ges: 1})
self.p('\n')
def startElement(self, name, attrs):