IDEA-302727 [Repair Utility] - Crash if IDE is in non-ascii path

GitOrigin-RevId: a6486afd75c502444fac25585aeebe4e0732bcab
This commit is contained in:
konstantin.annikov
2023-02-21 16:13:58 +00:00
committed by intellij-monorepo-bot
parent 33f67df6ff
commit a8fbaa5d0c
2 changed files with 18 additions and 0 deletions
+1
View File
@@ -62,6 +62,7 @@ func initPath() {
ideaBinary, err = helpers.SelectIdeaBinary()
logger.ExitWithExceptionOnError(err)
}
helpers.CurrentIde.CheckIfPathIsAllowed(ideaBinary)
helpers.CurrentIde.SetBinaryToWrokWith(ideaBinary)
}
+17
View File
@@ -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
}