[v3 linux] sanitize appId more thoroughly

This commit is contained in:
Travis McLane
2023-11-06 10:41:14 -06:00
parent 7c15f9098c
commit 8dbbdc4bf2
+9 -1
View File
@@ -4,6 +4,7 @@ package application
import (
"fmt"
"regexp"
"strings"
"unsafe"
@@ -192,7 +193,14 @@ func appName() string {
}
func appNew(name string) pointer {
nameC := C.CString(fmt.Sprintf("org.wails.%s", name))
// prevent leading number
if matched, _ := regexp.MatchString(`^\d+`, name); matched {
name = fmt.Sprintf("_%s", name)
}
name = strings.Replace(name, "(", "_", -1)
name = strings.Replace(name, ")", "_", -1)
appId := fmt.Sprintf("org.wails.%s", name)
nameC := C.CString(appId)
defer C.free(unsafe.Pointer(nameC))
return pointer(C.gtk_application_new(nameC, C.APPLICATION_DEFAULT_FLAGS))
}