From d4206b31283cc8032f8717b773cd40d8abf8394c Mon Sep 17 00:00:00 2001 From: Otto Urpelainen Date: Mar 19 2022 21:47:58 +0000 Subject: Retain url encoding when parsing specfile Source urls Source urls parsed from specfile are fetched during fedora-review run. This can only work reliably if the urls are valid in the specfile and they are kept in valid form during processing. Thus, call to 'unencode' when the specfile is parsed is removed. Unencode was there due to rhbz#920376, error when percent-encoded url was used as a Python format string. A better solution is to escape '%' before calling 'format'. There was a period of time when unencoded, invalid urls worked, because FancyURLopener could still process them. Since then, it has been replaced with urllib.request.urlopen, at which point things broke. Resolves #435 --- diff --git a/src/FedoraReview/spec_file.py b/src/FedoraReview/spec_file.py index a1fc62b..c661568 100644 --- a/src/FedoraReview/spec_file.py +++ b/src/FedoraReview/spec_file.py @@ -21,7 +21,6 @@ Spec file management. import re import sys -from six.moves.urllib.parse import unquote import rpm @@ -168,7 +167,9 @@ class SpecFile(object): continue tag = srctype + str(num) try: - result[tag] = self.spec.sourceHeader.format(unquote(url)) + # '%' has special meaning both in urls and Python format strings. + escaped = url.replace("%", "%%") + result[tag] = self.spec.sourceHeader.format(escaped) except Exception: raise SpecParseReviewError("Cannot parse %s url %s" % (tag, url)) return result