mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.13] gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284) (#128582)
gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284)
* Allow DOMParser.parse() to correctly handle DOMInputSource instances
that only have a systemId attribute set.
* Fix DOMEntityResolver.resolveEntity(), which was broken by the
Python 3.0 transition.
* Add Lib/test/test_xml_dom_xmlbuilder.py with few tests.
(cherry picked from commit 6ea04da270
)
Co-authored-by: Stephen Morton <git@tungol.org>
This commit is contained in:
parent
65da5db28a
commit
3714fd07c5
4 changed files with 100 additions and 5 deletions
|
@ -189,7 +189,7 @@ class DOMBuilder:
|
|||
options.filter = self.filter
|
||||
options.errorHandler = self.errorHandler
|
||||
fp = input.byteStream
|
||||
if fp is None and options.systemId:
|
||||
if fp is None and input.systemId:
|
||||
import urllib.request
|
||||
fp = urllib.request.urlopen(input.systemId)
|
||||
return self._parse_bytestream(fp, options)
|
||||
|
@ -247,10 +247,12 @@ class DOMEntityResolver(object):
|
|||
|
||||
def _guess_media_encoding(self, source):
|
||||
info = source.byteStream.info()
|
||||
if "Content-Type" in info:
|
||||
for param in info.getplist():
|
||||
if param.startswith("charset="):
|
||||
return param.split("=", 1)[1].lower()
|
||||
# import email.message
|
||||
# assert isinstance(info, email.message.Message)
|
||||
charset = info.get_param('charset')
|
||||
if charset is not None:
|
||||
return charset.lower()
|
||||
return None
|
||||
|
||||
|
||||
class DOMInputSource(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue