Fixed an issue where pgAdmin failed to connect when the Postgres password included special characters. #5847

This commit is contained in:
Akshay Joshi 2023-02-13 16:49:18 +05:30
parent 026334a71a
commit 0fd1e0963e
3 changed files with 21 additions and 19 deletions

View File

@ -21,6 +21,7 @@ New features
************
| `Issue #5832 <https://github.com/pgadmin-org/pgadmin4/issues/5832>`_ - Allow changing cardinality notation in ERD to use Chen notation.
| `Issue #5842 <https://github.com/pgadmin-org/pgadmin4/issues/5842>`_ - Add additional logging for successful logins and user creation.
Housekeeping
************
@ -32,3 +33,5 @@ Bug fixes
| `Issue #5685 <https://github.com/pgadmin-org/pgadmin4/issues/5685>`_ - Ensure that Grant column permission to a view is visible in the SQL tab.
| `Issue #5758 <https://github.com/pgadmin-org/pgadmin4/issues/5758>`_ - Fixed an issue where lock layout menu was not in sync with preferences.
| `Issue #5764 <https://github.com/pgadmin-org/pgadmin4/issues/5764>`_ - Fix an issue where the maintenance dialog for Materialized View gives an error.
| `Issue #5847 <https://github.com/pgadmin-org/pgadmin4/issues/5847>`_ - Fixed an issue where pgAdmin failed to connect when the Postgres password included special characters.

View File

@ -99,7 +99,7 @@ export function showServerPassword() {
})
.catch((err)=>{
return onFailure(
err, nodeObj, nodeData, treeNodeInfo, itemNodeData, status
err, null, nodeObj, nodeData, treeNodeInfo, itemNodeData, status
);
});
}}

View File

@ -29,6 +29,7 @@ from pgadmin.utils.exception import ConnectionLost, SSHTunnelConnectionLost,\
from pgadmin.utils.master_password import get_crypt_key
from pgadmin.utils.exception import ObjectGone
from pgadmin.utils.passexec import PasswordExec
from psycopg2.extensions import make_dsn
if config.SUPPORT_SSH_TUNNEL:
from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
@ -633,22 +634,21 @@ WHERE db.oid = {0}""".format(did))
This function is used to create connection string based on the
parameters.
"""
full_connection_string = \
'host=\'{0}\' port=\'{1}\' dbname=\'{2}\' user=\'{3}\''.format(
self.local_bind_host if self.use_ssh_tunnel else self.host,
self.local_bind_port if self.use_ssh_tunnel else self.port,
database, user)
self.display_connection_string = full_connection_string
dsn_args = dict()
dsn_args['host'] = \
self.local_bind_host if self.use_ssh_tunnel else self.host
dsn_args['port'] = \
self.local_bind_port if self.use_ssh_tunnel else self.port
dsn_args['dbname'] = database
dsn_args['user'] = user
# Make a copy to display the connection string on GUI.
display_dsn_args = dsn_args.copy()
# Password should not be visible into the connection string, so
# setting the value with password to 'xxxxxxx'.
if password:
self.display_connection_string = "{0} password='xxxxxxx'".format(
self.display_connection_string)
full_connection_string = "{0} password='{1}'".format(
full_connection_string, password)
display_dsn_args['password'] = 'xxxxxxx'
dsn_args['password'] = password
# Loop through all the connection parameters set in the server dialog.
if self.connection_params and isinstance(self.connection_params, dict):
@ -666,11 +666,10 @@ WHERE db.oid = {0}""".format(did))
value = self.local_bind_host if self.use_ssh_tunnel else \
value
self.display_connection_string = "{0} {1}='{2}'".format(
self.display_connection_string, key,
orig_value if with_complete_path else value)
dsn_args[key] = value
display_dsn_args[key] = orig_value if with_complete_path else \
value
full_connection_string = \
"{0} {1}='{2}'".format(full_connection_string, key, value)
self.display_connection_string = make_dsn(**display_dsn_args)
return full_connection_string
return make_dsn(**dsn_args)