File 0003-Fix-allow-sandbox-access-check-on-windows.patch of Package python-xmlschema

From 5e86e3dd241157ddb2a45d7f09fb657d0123b219 Mon Sep 17 00:00:00 2001
From: Daniel Hillier <daniel.hillier@gmail.com>
Date: Thu, 4 Jun 2020 12:05:06 +1000
Subject: [PATCH 3/4] Fix "allow" sandbox access check on windows

(cherry picked from commit aa8c38863ab23c13f67e7a3b5a8f0714102271d1)
---
 xmlschema/resources.py            | 6 ++----
 xmlschema/tests/test_resources.py | 9 ++++++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/xmlschema/resources.py b/xmlschema/resources.py
index d4f07ac..2a2c55e 100644
--- a/xmlschema/resources.py
+++ b/xmlschema/resources.py
@@ -355,10 +355,8 @@ class XMLResource(object):
                 raise XMLSchemaResourceError(
                     "block access to files out of sandbox requires 'base_url' to be set"
                 )
-            path = os.path.normpath(os.path.normcase(urlsplit(url).path))
-            base_path = os.path.normpath(os.path.normcase(urlsplit(self._base_url).path))
-            if not path.startswith(base_path):
-                raise XMLSchemaResourceError("block access to out of sandbox file {}".format(path))
+            if not url.startswith(normalize_url(self._base_url)):
+                raise XMLSchemaResourceError("block access to out of sandbox file {}".format(url))
 
     def _fromsource(self, source):
         url = None
diff --git a/xmlschema/tests/test_resources.py b/xmlschema/tests/test_resources.py
index c8264c5..51c0c20 100644
--- a/xmlschema/tests/test_resources.py
+++ b/xmlschema/tests/test_resources.py
@@ -408,10 +408,13 @@ class TestResources(unittest.TestCase):
             "block access to files out of sandbox requires 'base_url' to be set",
         )
 
+        source = "/tmp/vehicles.xsd"
         with self.assertRaises(XMLSchemaResourceError) as ctx:
-            XMLResource("/tmp/vehicles.xsd", base_url=base_url, allow='sandbox')
-        self.assertEqual(str(ctx.exception),
-                         "block access to out of sandbox file /tmp/vehicles.xsd")
+            XMLResource(source, base_url=base_url, allow='sandbox')
+        self.assertEqual(
+            str(ctx.exception),
+            "block access to out of sandbox file {}".format(normalize_url(source)),
+        )
 
         with self.assertRaises(TypeError) as ctx:
             XMLResource("https://xmlschema.test/vehicles.xsd", allow=None)
-- 
2.29.2

openSUSE Build Service is sponsored by