summaryrefslogtreecommitdiff
path: root/app-text/calibre/files/e9cc00560a28f56a303cca97630ab58e519dd9c8.patch
blob: deae34e201e39d80f714e7f9ea41c049ce99d905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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