allow only a-zA-Z for keyboard layout

This commit is contained in:
Miroslav Šedivý 2020-06-16 02:39:15 +02:00
parent e6c7dd0122
commit fcca903ae9

View File

@ -13,6 +13,7 @@ import (
"sync"
"time"
"unsafe"
"regexp"
"n.eko.moe/neko/internal/types"
)
@ -214,6 +215,10 @@ func SetKeyboard(layout string) {
mu.Lock()
defer mu.Unlock()
if !regexp.MustCompile(`^[a-zA-Z]+$`).MatchString(layout) {
return
}
layoutUnsafe := C.CString(layout)
defer C.free(unsafe.Pointer(layoutUnsafe))