defusedxml icon indicating copy to clipboard operation
defusedxml copied to clipboard

Missing XMLParser options WITHOUT deprecated solution

Open dga-nagra opened this issue 2 years ago • 1 comments

Hi,

Sorry for re-creating a new issue but it seems that you are not seeing closed ones. It the #102 issue, the solution proposed is depracted as stated in #33 . This solution should therefore not be used and it won't be accepted by CI/CD. For reminder, the solution was the following:

>>> import lxml.etree
>>> import defusedxml.lxml
>>>
>>> parser = lxml.etree.Parser(remove_blank_text=True, resolve_entities=False)
>>> lookup = lxml.etree.ElementDefaultClassLookup(defusedxml.lxml.RestrictedElement)
>>> parser.set_element_class_lookup(lookup)
>>> e = defusedxml.lxml.XML("<root><el/>  </root>", parser=parser)
>>> lxml.etree.tostring(e)
b'<root><el/></root>'

The main point of the solution proposed is the use of the defused.lxml.RestrictedElement , then defused.lxml.XML which are only part of the defused.lxml module.

There should be a non-deprecated way of doing it. If another solution exists that is not deprecated, then I would gladly be informed of it. Otherwise, the solutions are to:

  • Remove lxml deprecation
  • Move the necessary to another non-deprecated module
  • Match the official lxml library's API

Please, don't close this issue right away after responding. Thank you.

dga-nagra avatar Nov 14 '23 07:11 dga-nagra

Hi @tiran , since the issue #102 and #33 were answer by you, do you have any feedback on this?

dga-nagra avatar Mar 07 '24 08:03 dga-nagra