diff --git a/native/repair-utility/cmd/root.go b/native/repair-utility/cmd/root.go index e54071b72bef..171c277f8bf6 100644 --- a/native/repair-utility/cmd/root.go +++ b/native/repair-utility/cmd/root.go @@ -62,6 +62,7 @@ func initPath() { ideaBinary, err = helpers.SelectIdeaBinary() logger.ExitWithExceptionOnError(err) } + helpers.CurrentIde.CheckIfPathIsAllowed(ideaBinary) helpers.CurrentIde.SetBinaryToWrokWith(ideaBinary) } diff --git a/native/repair-utility/helpers/ide.go b/native/repair-utility/helpers/ide.go index c30769db1e53..36f914cb49cf 100644 --- a/native/repair-utility/helpers/ide.go +++ b/native/repair-utility/helpers/ide.go @@ -2,6 +2,7 @@ package helpers import ( "encoding/json" + "errors" "io/ioutil" "log" "os" @@ -11,6 +12,7 @@ import ( "runtime" "strconv" "strings" + "unicode" ) type IdeInfo struct { @@ -299,3 +301,18 @@ func (ide *IDE) RunIde() *os.Process { logger.DebugLogger.Println("Started the IDE with PID " + strconv.Itoa(cmd.Process.Pid)) return cmd.Process } + +func (ide *IDE) CheckIfPathIsAllowed(path string) { + if !isASCII(path) { + logger.FatalLogger.Fatal(errors.New("The path contains non-ASCII characters. IDE cannot run here: " + path)) + } +} + +func isASCII(s string) bool { + for _, c := range s { + if c > unicode.MaxASCII { + return false + } + } + return true +}