mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 13:35:23 +02:00
Merge pull request #3163 from michael-genson/fix/url-encode-postgres-passwords
fix: URL-Encode Postgres Password
This commit is contained in:
commit
fe3bd95c85
2 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from pydantic import BaseModel, PostgresDsn
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
@ -48,7 +49,7 @@ class PostgresProvider(AbstractDBProvider, BaseSettings):
|
|||
PostgresDsn.build(
|
||||
scheme="postgresql",
|
||||
username=self.POSTGRES_USER,
|
||||
password=self.POSTGRES_PASSWORD,
|
||||
password=urlparse.quote_plus(self.POSTGRES_PASSWORD),
|
||||
host=host,
|
||||
path=f"{self.POSTGRES_DB or ''}",
|
||||
)
|
||||
|
|
|
@ -38,6 +38,15 @@ def test_pg_connection_args(monkeypatch):
|
|||
assert app_settings.DB_URL == "postgresql://mealie:mealie@postgres:5432/mealie"
|
||||
|
||||
|
||||
def test_pg_connection_url_encode_password(monkeypatch):
|
||||
monkeypatch.setenv("DB_ENGINE", "postgres")
|
||||
monkeypatch.setenv("POSTGRES_SERVER", "postgres")
|
||||
monkeypatch.setenv("POSTGRES_PASSWORD", "please,url#encode/this?password")
|
||||
get_app_settings.cache_clear()
|
||||
app_settings = get_app_settings()
|
||||
assert app_settings.DB_URL == "postgresql://mealie:please%2Curl%23encode%2Fthis%3Fpassword@postgres:5432/mealie"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class SMTPValidationCase:
|
||||
host: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue