Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Quote in username errors dapr init #972 #1322

Merged
merged 9 commits into from
Jun 26, 2023
1 change: 1 addition & 0 deletions pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ func moveFileToPath(filepath string, installLocation string) (string, error) {
p := os.Getenv("PATH")

if !strings.Contains(strings.ToLower(p), strings.ToLower(destDir)) {
destDir = utils.SanitizeDir(destDir)
pathCmd := "[System.Environment]::SetEnvironmentVariable('Path',[System.Environment]::GetEnvironmentVariable('Path','user') + '" + fmt.Sprintf(";%s", destDir) + "', 'user')"
_, err := utils.RunCmdAndWait("powershell", pathCmd)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,10 @@ func FindFileInDir(dirPath, fileName string) (string, error) {
}
return filePath, nil
}

// SanitizeDir corrects any syntactical errors in the passed directory.
shubham1172 marked this conversation as resolved.
Show resolved Hide resolved
func SanitizeDir(destDir string) string {
correctedDestDir := destDir
correctedDestDir = strings.ReplaceAll(correctedDestDir, "'", "''")
return correctedDestDir
mohitpalsingh marked this conversation as resolved.
Show resolved Hide resolved
}