From b52dd5f32cce104260d77b05b32e2e07aa7f0915 Mon Sep 17 00:00:00 2001 From: "arcoalien@qq.com" Date: Mon, 17 Jan 2022 11:19:27 +0800 Subject: [PATCH] =?UTF-8?q?fix=20issue=20=E5=AF=86=E7=A0=81=E4=B8=AD?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=9C=89URL=E4=B8=AD=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E7=9A=84=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E6=97=B6=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- py_opengauss/resolved/riparse.py | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index effa8ab..4508272 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ # multi IP support, will return PRIMARY instance connect: >>> db = py_opengauss.open('opengauss://user:password@host1:123,host2:456/database') -# Connect to 'postgres' at localhost. +# Connect to 'postgres' at localhost with default user and password in the env, which only support postgresql. +# 注意: 该连接方式只支持PG, 不支持openGauss, 对于openGauss, 必须要输入user和password >>> db = py_opengauss.open('localhost/postgres') ``` diff --git a/py_opengauss/resolved/riparse.py b/py_opengauss/resolved/riparse.py index 523989a..ee8b63c 100644 --- a/py_opengauss/resolved/riparse.py +++ b/py_opengauss/resolved/riparse.py @@ -133,21 +133,25 @@ def split(s): end_of_netloc = end - path_pos = s.find('/', pos) - if path_pos == -1: + split_loc = s.rfind('@') + if split_loc == -1: + return scheme, netloc, path, query, fragment + + path_pos = s.rfind('/', pos) + if path_pos == -1 or path_pos < split_loc: path_pos = None else: end_of_netloc = path_pos - query_pos = s.find('?', pos) - if query_pos == -1: + query_pos = s.rfind('?', pos) + if query_pos == -1 or query_pos < split_loc: query_pos = None elif path_pos is None or query_pos < path_pos: path_pos = None end_of_netloc = query_pos - fragment_pos = s.find('#', pos) - if fragment_pos == -1: + fragment_pos = s.rfind('#', pos) + if fragment_pos == -1 or fragment_pos < split_loc: fragment_pos = None else: if query_pos is not None and fragment_pos < query_pos: @@ -244,7 +248,7 @@ def split_netloc(netloc, fieldproc = unescape): Set `fieldproc` to `str` if the components' percent escapes should not be decoded. """ - pos = netloc.find('@') + pos = netloc.rfind('@') if pos == -1: # No user information pos = 0 -- Gitee