File tree Expand file tree Collapse file tree 4 files changed +35
-6
lines changed
backups/backups/usecases/postgresql
restores/usecases/postgresql
frontend/src/shared/theme Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -719,11 +719,15 @@ func (uc *CreatePostgresqlBackupUsecase) createTempPgpassFile(
719719 return "" , nil
720720 }
721721
722+ escapedHost := tools .EscapePgpassField (pgConfig .Host )
723+ escapedUsername := tools .EscapePgpassField (pgConfig .Username )
724+ escapedPassword := tools .EscapePgpassField (password )
725+
722726 pgpassContent := fmt .Sprintf ("%s:%d:*:%s:%s" ,
723- pgConfig . Host ,
727+ escapedHost ,
724728 pgConfig .Port ,
725- pgConfig . Username ,
726- password ,
729+ escapedUsername ,
730+ escapedPassword ,
727731 )
728732
729733 tempDir , err := os .MkdirTemp ("" , "pgpass" )
Original file line number Diff line number Diff line change @@ -564,11 +564,15 @@ func (uc *RestorePostgresqlBackupUsecase) createTempPgpassFile(
564564 return "" , nil
565565 }
566566
567+ escapedHost := tools .EscapePgpassField (pgConfig .Host )
568+ escapedUsername := tools .EscapePgpassField (pgConfig .Username )
569+ escapedPassword := tools .EscapePgpassField (password )
570+
567571 pgpassContent := fmt .Sprintf ("%s:%d:*:%s:%s" ,
568- pgConfig . Host ,
572+ escapedHost ,
569573 pgConfig .Port ,
570- pgConfig . Username ,
571- password ,
574+ escapedUsername ,
575+ escapedPassword ,
572576 )
573577
574578 tempDir , err := os .MkdirTemp ("" , "pgpass" )
Original file line number Diff line number Diff line change 66 "os"
77 "path/filepath"
88 "runtime"
9+ "strings"
910
1011 env_utils "postgresus-backend/internal/util/env"
1112)
@@ -151,6 +152,24 @@ func VerifyPostgresesInstallation(
151152 logger .Info ("All PostgreSQL version-specific client tools verification completed successfully!" )
152153}
153154
155+ // EscapePgpassField escapes special characters in a field value for .pgpass file format.
156+ // According to PostgreSQL documentation, the .pgpass file format requires:
157+ // - Backslash (\) must be escaped as \\
158+ // - Colon (:) must be escaped as \:
159+ // Additionally, newlines and carriage returns are removed to prevent format corruption.
160+ func EscapePgpassField (field string ) string {
161+ // Remove newlines and carriage returns that would break .pgpass format
162+ field = strings .ReplaceAll (field , "\r " , "" )
163+ field = strings .ReplaceAll (field , "\n " , "" )
164+
165+ // Escape backslashes first (order matters!)
166+ // Then escape colons
167+ field = strings .ReplaceAll (field , "\\ " , "\\ \\ " )
168+ field = strings .ReplaceAll (field , ":" , "\\ :" )
169+
170+ return field
171+ }
172+
154173func getPostgresqlBasePath (
155174 version PostgresqlVersion ,
156175 envMode env_utils.EnvMode ,
Original file line number Diff line number Diff line change @@ -16,10 +16,12 @@ function getSystemTheme(): ResolvedTheme {
1616function getStoredTheme ( ) : ThemeMode {
1717 if ( typeof window !== 'undefined' ) {
1818 const stored = localStorage . getItem ( THEME_STORAGE_KEY ) ;
19+
1920 if ( stored === 'light' || stored === 'dark' || stored === 'system' ) {
2021 return stored ;
2122 }
2223 }
24+
2325 return 'system' ;
2426}
2527
You can’t perform that action at this time.
0 commit comments