Blame SOURCES/CVE-2019-11236.patch

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