mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-30 17:53:31 -04:00 
			
		
		
		
	Merge pull request #3163 from michael-genson/fix/url-encode-postgres-passwords
fix: URL-Encode Postgres Password
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user