Validate jump label characters

Also extend default jump labels
pull/581/head
Junegunn Choi 8 years ago
parent f498a9b3fb
commit 7ed9f83662
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -38,7 +38,7 @@ const (
defaultHistoryMax int = 1000 defaultHistoryMax int = 1000
// Jump labels // Jump labels
defaultJumpLabels string = "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM,<.>/?!@#$%^&*<>/?()[{]}" defaultJumpLabels string = "asdfghjklqwertyuiopzxcvbnm1234567890ASDFGHJKLQWERTYUIOPZXCVBNM`~;:,<.>/?'\"!@#$%^&*()[{]}-_=+"
) )
// fzf events // fzf events

@ -724,6 +724,7 @@ func parseOptions(opts *Options, allArgs []string) {
opts.History.maxSize = historyMax opts.History.maxSize = historyMax
} }
} }
validateJumpLabels := false
for i := 0; i < len(allArgs); i++ { for i := 0; i < len(allArgs); i++ {
arg := allArgs[i] arg := allArgs[i]
switch arg { switch arg {
@ -817,6 +818,7 @@ func parseOptions(opts *Options, allArgs []string) {
opts.InlineInfo = false opts.InlineInfo = false
case "--jump-labels": case "--jump-labels":
opts.JumpLabels = nextString(allArgs, &i, "label characters required") opts.JumpLabels = nextString(allArgs, &i, "label characters required")
validateJumpLabels = true
case "-1", "--select-1": case "-1", "--select-1":
opts.Select1 = true opts.Select1 = true
case "+1", "--no-select-1": case "+1", "--no-select-1":
@ -927,6 +929,14 @@ func parseOptions(opts *Options, allArgs []string) {
if len(opts.JumpLabels) == 0 { if len(opts.JumpLabels) == 0 {
errorExit("empty jump labels") errorExit("empty jump labels")
} }
if validateJumpLabels {
for _, r := range opts.JumpLabels {
if r < 32 || r > 126 {
errorExit("non-ascii jump labels are not allowed")
}
}
}
} }
func postProcessOptions(opts *Options) { func postProcessOptions(opts *Options) {

Loading…
Cancel
Save