You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

4 years ago
  1. # defusedxml
  2. #
  3. # Copyright (c) 2013 by Christian Heimes <christian@python.org>
  4. # Licensed to PSF under a Contributor Agreement.
  5. # See http://www.python.org/psf/license for licensing details.
  6. """Defused xml.dom.pulldom
  7. """
  8. from __future__ import print_function, absolute_import
  9. from xml.dom.pulldom import parse as _parse
  10. from xml.dom.pulldom import parseString as _parseString
  11. from .sax import make_parser
  12. __origin__ = "xml.dom.pulldom"
  13. def parse(stream_or_string, parser=None, bufsize=None, forbid_dtd=False,
  14. forbid_entities=True, forbid_external=True):
  15. if parser is None:
  16. parser = make_parser()
  17. parser.forbid_dtd = forbid_dtd
  18. parser.forbid_entities = forbid_entities
  19. parser.forbid_external = forbid_external
  20. return _parse(stream_or_string, parser, bufsize)
  21. def parseString(string, parser=None, forbid_dtd=False,
  22. forbid_entities=True, forbid_external=True):
  23. if parser is None:
  24. parser = make_parser()
  25. parser.forbid_dtd = forbid_dtd
  26. parser.forbid_entities = forbid_entities
  27. parser.forbid_external = forbid_external
  28. return _parseString(string, parser)