Skip to content

Commit e2e055b

Browse files
Fix special characters in DB password not being URL encoded (#361)
1 parent 3c99551 commit e2e055b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [unreleased]
44

5+
### Fixed
6+
7+
* database: Fixed special characters in password not being URL encoded.
8+
59
### Performance
610

711
* context: Do not reinitialize config when adding a single index.

src/dipdup/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from typing import TypeVar
3131
from typing import Union
3232
from typing import cast
33+
from urllib.parse import quote_plus
3334
from urllib.parse import urlparse
3435

3536
from pydantic import validator
@@ -120,7 +121,7 @@ class PostgresDatabaseConfig:
120121
def connection_string(self) -> str:
121122
# NOTE: `maxsize=1` is important! Concurrency will be broken otherwise.
122123
# NOTE: https://github.com/tortoise/tortoise-orm/issues/792
123-
connection_string = f'{self.kind}://{self.user}:{self.password}@{self.host}:{self.port}/{self.database}?maxsize=1'
124+
connection_string = f'{self.kind}://{self.user}:{quote_plus(self.password)}@{self.host}:{self.port}/{self.database}?maxsize=1'
124125
if self.schema_name != DEFAULT_POSTGRES_SCHEMA:
125126
connection_string += f'&schema={self.schema_name}'
126127
return connection_string

0 commit comments

Comments
 (0)