From 68e509d58063c11d0a10f0c5e58c071c4f43cc2d Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Sat, 19 Jan 2019 14:26:57 +1100 Subject: [PATCH] Add a patch to correct upstream bug with matching URIs. Closes: bug#919599. --- debian/changelog | 8 +++ .../match-uri-without-hostname-case.patch | 50 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 59 insertions(+) create mode 100644 debian/patches/match-uri-without-hostname-case.patch diff --git a/debian/changelog b/debian/changelog index 221653c..8e63aa7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +python-httpretty (0.9.5-3) UNRELEASED; urgency=medium + + [ Ben Finney ] + * Add a patch to correct upstream bug with matching URIs. + Closes: bug#919599. + + -- + python-httpretty (0.9.5-2) unstable; urgency=medium * Add RES_OPTIONS=attempts:0 to avoid resolving in unit tests. diff --git a/debian/patches/match-uri-without-hostname-case.patch b/debian/patches/match-uri-without-hostname-case.patch new file mode 100644 index 0000000..95ae010 --- /dev/null +++ b/debian/patches/match-uri-without-hostname-case.patch @@ -0,0 +1,50 @@ +Description: Match URI without letter case in hostname. + The URI matching should ignore the hostname letter case, so that + intermediate “normalising” of the hostname does not affect whether + the URI matches. +Bug: https://github.com/gabrielfalcao/HTTPretty/issues/369 +Bug-Debian: http://bugs.debian.org/919599 +Author: Ben Finney +Forwarded: https://github.com/gabrielfalcao/HTTPretty/issues/369#issuecomment-455744083 +Last-Update: 2019-01-19 + +diff --git a/tests/unit/test_httpretty.py b/tests/unit/test_httpretty.py +--- a/tests/unit/test_httpretty.py ++++ b/tests/unit/test_httpretty.py +@@ -450,1 +450,23 @@ def test_socktype_good_python_version(): + HTTPretty.disable() ++ ++ ++def test_match_http_address_should_ignore_hostname_case(): ++ "HTTPretty.match_http_address should ignore case of hostname." ++ ++ for (register_hostname, match_hostname) in [ ++ ('foo.example.com', 'foo.example.com'), ++ ('FOO.example.COM', 'foo.example.com'), ++ ('foo.EXAMPLE.com', 'foo.example.com'), ++ ('fOo.eXaMpLe.com', 'foo.example.com'), ++ ('foo.example.com', 'FOO.example.COM'), ++ ('foo.example.com', 'foo.EXAMPLE.com'), ++ ('foo.example.com', 'fOo.eXaMpLe.com'), ++ ]: ++ HTTPretty.register_uri( ++ HTTPretty.GET, ++ "http://{hostname}/".format(hostname=register_hostname), ++ body="yay", ++ ) ++ assert HTTPretty.match_http_address(match_hostname, 80) ++ ++ + +diff --git a/httpretty/core.py b/httpretty/core.py +--- a/httpretty/core.py ++++ b/httpretty/core.py +@@ -1085,7 +1085,7 @@ class httpretty(HttpBaseClass): + or matcher.regex.pattern.startswith(pattern): + return matcher + +- elif matcher.info.hostname == hostname: ++ elif (matcher.info.hostname.lower() == hostname.lower()): + return matcher + return None + diff --git a/debian/patches/series b/debian/patches/series index 14929dd..e5ed69b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ remove-with-randomly.patch remove-broken-test.patch remove-network-access-test.patch +match-uri-without-hostname-case.patch -- GitLab