ITADN

Missing XMLParser options WITHOUT deprecated solution

#103Opendga-nagra 创建于 2023-11-14
D
dga-nagracommented
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: ```python >>> 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.
1 条评论