dave2wave commented on issue #763:
URL:
https://github.com/apache/tooling-trusted-releases/issues/763#issuecomment-3992786207
`pydantic_xml` is requiring `lxml`. This means we should address this by
converting to `defusedxml` or by configuring a safe parser.
```python
from lxml import etree
safe_parser = etree.XMLParser(
resolve_entities=False,
load_dtd=False,
no_network=True,
)
root = etree.fromstring(xml_data, parser=safe_parser)
model = MyModel.from_xml_tree(root)
```
`defusedxml`:
```python
from defusedxml.ElementTree import fromstring
from pydantic_xml import BaseXmlModel
class Payload(BaseXmlModel):
id: int
name: str
def parse_xml_secure(xml_bytes: bytes) -> Payload:
root = fromstring(xml_bytes)
return Payload.from_xml_tree(root)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]