From 3573fe0726f8dde1c5714b7d501f6c43d97ce731 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi <fme@odoo.com> Date: Tue, 23 May 2023 16:06:33 +0000 Subject: [PATCH] [FIX] sql_db: use psycopg2.extensions.parse_dsn for dsn parsing Before this patch the naive dsn parser `_dsn_to_dict` would choke on `application_name` containing spaces or the equal sign. closes odoo/odoo#122010 Signed-off-by: Fabien Meghazi (fme) <fme@odoo.com> --- odoo/sql_db.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/odoo/sql_db.py b/odoo/sql_db.py index 966719514bcc..590816a1f737 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -688,14 +688,11 @@ class ConnectionPool(object): ignore_keys = ['password'] dsn1, dsn2 = ({ alias_keys.get(key, key): str(value) - for key, value in (isinstance(dsn, str) and self._dsn_to_dict(dsn) or dsn).items() + for key, value in (psycopg2.extensions.parse_dsn(dsn) if isinstance(dsn, str) else dsn).items() if key not in ignore_keys } for dsn in (dsn1, dsn2)) return dsn1 == dsn2 - def _dsn_to_dict(self, dsn): - return dict(value.split('=', 1) for value in dsn.strip().split()) - class Connection(object): """ A lightweight instance of a connection to postgres -- GitLab