mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-14 15:23:27 +00:00
Merge pull request #495 from plasticrake/environment-variables
Replace special characters in environment variable name with underscores
This commit is contained in:
@@ -173,6 +173,15 @@ func GetPasswordFromPreference(preference Preference, passwordType string) strin
|
||||
if password, found := os.LookupEnv(name); found && password != "" {
|
||||
return password
|
||||
}
|
||||
|
||||
re := regexp.MustCompile(`[^a-zA-Z0-9_]`)
|
||||
namePlain := re.ReplaceAllString(name, "_")
|
||||
if namePlain != name {
|
||||
LOG_DEBUG("PASSWORD_ENV_VAR", "Reading the environment variable %s", namePlain)
|
||||
if password, found := os.LookupEnv(namePlain); found && password != "" {
|
||||
return password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the password is stored in the preference, there is no need to include the storage name
|
||||
|
||||
Reference in New Issue
Block a user