36 lines
1.3 KiB
Diff
36 lines
1.3 KiB
Diff
From e9cc00560a28f56a303cca97630ab58e519dd9c8 Mon Sep 17 00:00:00 2001
|
|
From: Kovid Goyal <kovid@kovidgoyal.net>
|
|
Date: Mon, 8 Jan 2024 09:12:35 +0530
|
|
Subject: [PATCH] Fix #2048475 [Tests fail with lxml
|
|
5.0](https://bugs.launchpad.net/calibre/+bug/2048475)
|
|
|
|
---
|
|
src/calibre/utils/xml_parse.py | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/calibre/utils/xml_parse.py b/src/calibre/utils/xml_parse.py
|
|
index a31c6ed83ed7..339538b90057 100644
|
|
--- a/src/calibre/utils/xml_parse.py
|
|
+++ b/src/calibre/utils/xml_parse.py
|
|
@@ -36,6 +36,11 @@ def safe_xml_fromstring(string_or_bytes, recover=True):
|
|
return ans
|
|
|
|
|
|
+def unsafe_xml_fromstring(string_or_bytes):
|
|
+ parser = etree.XMLParser(resolve_entities=True)
|
|
+ return fs(string_or_bytes, parser=parser)
|
|
+
|
|
+
|
|
def find_tests():
|
|
import unittest, tempfile, os
|
|
from calibre.constants import iswindows
|
|
@@ -61,7 +66,7 @@ def t(tid, val, expected, safe=True):
|
|
raw = templ.format(id=tid, val=val)
|
|
err = None
|
|
try:
|
|
- root = safe_xml_fromstring(raw) if safe else etree.fromstring(raw)
|
|
+ root = safe_xml_fromstring(raw) if safe else unsafe_xml_fromstring(raw)
|
|
except Exception as e:
|
|
err = str(e)
|
|
root = None
|