From a31c1ae992122e67cbd03ed6f4f74abcf990cc3d Mon Sep 17 00:00:00 2001 From: vimiix Date: Wed, 6 Apr 2022 18:47:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9C=AA=E5=9C=A8dsn=E4=B8=AD=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E7=94=A8=E6=88=B7=E5=AF=86=E7=A0=81=E6=97=B6,?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py_opengauss/project.py | 2 +- py_opengauss/resolved/riparse.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/py_opengauss/project.py b/py_opengauss/project.py index 5da1c5f..dc5e988 100644 --- a/py_opengauss/project.py +++ b/py_opengauss/project.py @@ -8,5 +8,5 @@ identity = 'http://github.com/vimiix/py-opengauss' meaculpa = 'Python+openGauss' abstract = 'Driver and tools library for openGauss' -version_info = (1, 3, 6) # dev based on py-postgresql version 1.3.0 +version_info = (1, 3, 8) # dev based on py-postgresql version 1.3.0 version = '.'.join(map(str, version_info)) diff --git a/py_opengauss/resolved/riparse.py b/py_opengauss/resolved/riparse.py index ee8b63c..0c205d3 100644 --- a/py_opengauss/resolved/riparse.py +++ b/py_opengauss/resolved/riparse.py @@ -40,6 +40,7 @@ percent encoded variant is decoded. """ import re import copy +from urllib.parse import quote pct_encode = '%%%0.2X'.__mod__ unescaped = '%' + ''.join([chr(x) for x in range(0, 33)]) @@ -131,11 +132,18 @@ def split(s): scheme = None break - end_of_netloc = end + split_loc = s.rfind('@', pos) + if split_loc != -1: + # quote password to a safe string + userpw = s[pos:split_loc].split(':', 1) + if len(userpw) == 2: + user, pw = userpw + safe_pw = quote(pw) + s = s[:pos] + user + ':' + safe_pw + s[split_loc:] + # update end pos from new string + end = len(s) - split_loc = s.rfind('@') - if split_loc == -1: - return scheme, netloc, path, query, fragment + end_of_netloc = end path_pos = s.rfind('/', pos) if path_pos == -1 or path_pos < split_loc: -- Gitee