From 1898fc46819caed9ae2b3cbbd6160a754151c225 Mon Sep 17 00:00:00 2001 From: Rokoucha Date: Sat, 31 Jul 2021 17:00:47 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20base64=20=E3=82=A8=E3=83=B3=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=87=E3=82=A3=E3=83=B3=E3=82=B0=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- urlutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/urlutil.py b/urlutil.py index 93f05ff..96ae0db 100644 --- a/urlutil.py +++ b/urlutil.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +import base64 import re # urllib2.Request で開く url と headers を生成する @@ -14,7 +15,7 @@ def getUrlInfo(server_url): if match is not None: # BASIC 認証 result["url"] = match.group(1) + "://" + match.group(4); - result["headers"]["authorization"] = "Basic " + (match.group(2) + ":" + match.group(3)).encode("base64")[:-1] + result["headers"]["authorization"] = "Basic " + base64.b64encode((match.group(2) + ":" + match.group(3)).encode()).decode(); else: match = re.search(r"^(http|https)://(.+)", server_url) result["url"] = match.group(1) + "://" + match.group(2);