From 6e46624fe0fb37a9dfec42a50bfa60dfe6f8c8b0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 22 Nov 2019 15:20:45 +0100 Subject: [PATCH] Fixes #4017 --- lib/core/common.py | 11 ++++++++--- lib/core/settings.py | 2 +- lib/request/redirecthandler.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 0178657d0..21c9845e2 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -4360,11 +4360,16 @@ def asciifyUrl(url, forceQuote=False): if all(char in string.printable for char in url): return getText(url) + hostname = parts.hostname + + if isinstance(hostname, six.binary_type): + hostname = getUnicode(hostname) + # idna-encode domain try: - hostname = parts.hostname.encode("idna") - except LookupError: - hostname = parts.hostname.encode("punycode") + hostname = hostname.encode("idna") + except: + hostname = hostname.encode("punycode") # UTF8-quote the other parts. We check each part individually if # if needs to be quoted - that should catch some additional user diff --git a/lib/core/settings.py b/lib/core/settings.py index f729fe017..80302bf5f 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.3.11.94" +VERSION = "1.3.11.95" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index 3e7177709..e7889941f 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -170,7 +170,7 @@ class SmartRedirectHandler(_urllib.request.HTTPRedirectHandler): threadData.lastRedirectURL = (threadData.lastRequestUID, redurl) result.redcode = code - result.redurl = redurl + result.redurl = getUnicode(redurl) return result http_error_301 = http_error_303 = http_error_307 = http_error_302