Blame SOURCES/CVE-2019-11236.patch

06bcfa
From b40eb0f43daecc6e2e3ce47b0be49cf570d02adc Mon Sep 17 00:00:00 2001
06bcfa
From: Lumir Balhar <lbalhar@redhat.com>
06bcfa
Date: Thu, 9 Jan 2020 11:14:58 +0100
06bcfa
Subject: [PATCH] CVE-2019-9740
06bcfa
06bcfa
---
06bcfa
 util/url.py | 7 +++++++
06bcfa
 1 file changed, 7 insertions(+)
06bcfa
06bcfa
diff --git a/util/url.py b/util/url.py
06bcfa
index 6b6f996..2784c85 100644
06bcfa
--- a/util/url.py
06bcfa
+++ b/util/url.py
06bcfa
@@ -1,5 +1,6 @@
06bcfa
 from __future__ import absolute_import
06bcfa
 from collections import namedtuple
06bcfa
+import re
06bcfa
 
06bcfa
 from ..exceptions import LocationParseError
06bcfa
 
06bcfa
@@ -10,6 +11,8 @@ url_attrs = ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment']
06bcfa
 # urllib3 infers URLs without a scheme (None) to be http.
06bcfa
 NORMALIZABLE_SCHEMES = ('http', 'https', None)
06bcfa
 
06bcfa
+_contains_disallowed_url_pchar_re = re.compile('[\x00-\x20\x7f]')
06bcfa
+from ..packages.six.moves.urllib.parse import quote
06bcfa
 
06bcfa
 class Url(namedtuple('Url', url_attrs)):
06bcfa
     """
06bcfa
@@ -155,6 +158,10 @@ def parse_url(url):
06bcfa
         # Empty
06bcfa
         return Url()
06bcfa
 
06bcfa
+    # Prevent CVE-2019-9740.
06bcfa
+    # adapted from https://github.com/python/cpython/pull/12755
06bcfa
+    url = _contains_disallowed_url_pchar_re.sub(lambda match: quote(match.group()), url)
06bcfa
+
06bcfa
     scheme = None
06bcfa
     auth = None
06bcfa
     host = None
06bcfa
-- 
06bcfa
2.24.1
06bcfa