File fix-urlgrab-file-schema-comparison.patch of Package python-urlgrabber.28867
From ade190eee5af949d9043b72f19041ec575f47947 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Wed, 1 Mar 2023 14:00:08 +0000
Subject: [PATCH] Fix comparison to work with expected bytes string
The urlgrab function initially coverts given url to bytes string
via the _to_utf8() helper. This make "url" parameter to be bytes,
and therefore we need to fix the this comparison
Prevent error due bytes when grabbing local paths
>>> urlgrabber.urlgrab("file://tmp/foobar/")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/urlgrabber/grabber.py", line 806, in urlgrab
return default_grabber.urlgrab(url, filename, **kwargs)
File "/usr/lib/python3.6/site-packages/urlgrabber/grabber.py", line 1216, in urlgrab
path = url2pathname(path)
File "/usr/lib64/python3.6/urllib/request.py", line 1684, in url2pathname
return unquote(pathname)
File "/usr/lib64/python3.6/urllib/parse.py", line 640, in unquote
if '%' not in string:
TypeError: a bytes-like object is required, not 'str'
---
urlgrabber/grabber.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 7afe53e..0cfc9b3 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -1233,12 +1233,12 @@ class URLGrabber(object):
if not filename:
# This is better than nothing.
filename = 'index.html'
- if scheme == 'file' and not opts.copy_local:
+ if scheme == b'file' and not opts.copy_local:
# just return the name of the local file - don't make a
# copy currently
- path = url2pathname(path)
+ path = url2pathname(_urlunquote_convert(path))
if host:
- path = os.path.normpath('//' + host + path)
+ path = os.path.normpath('//' + _urlunquote_convert(host) + path)
if not os.path.exists(path):
err = URLGrabError(2,
_('Local file does not exist: %s') % (path, ))
--
2.39.2