From 71f8f63102766bca66c3258b0a00454b958aa1ab Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sun, 18 Sep 2016 17:54:18 +0530 Subject: [PATCH] rcfile: reject several ASCII chars from 64 to 124 --- doc/syntax/nanorc.nanorc | 4 ++-- src/rcfile.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/syntax/nanorc.nanorc b/doc/syntax/nanorc.nanorc index 9f3278d..8a709f1 100644 --- a/doc/syntax/nanorc.nanorc +++ b/doc/syntax/nanorc.nanorc @@ -10,8 +10,8 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|ma icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>" icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+" -icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" -icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" +icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|space|[]]|[0-9^_=+;:'\",./<>\?-])|M-([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-]))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" +icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|space|[]]|[0-9^_=+;:'\",./<>\?-])|M-([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-]))([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$" icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>" diff --git a/src/rcfile.c b/src/rcfile.c index 2a12d38..d2243c3 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -400,7 +400,9 @@ void parse_binding(char *ptr, bool dobind) rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); goto free_copy; } else if ((keycopy[0] == 'M' && keycopy[1] != '-') || - (keycopy[0] == '^' && ((keycopy[1] < 64 || keycopy[1] > 127) || + (keycopy[0] == '^' && + ((keycopy[1] <= 64 || keycopy[1] >= 123) || + keycopy[1] == 91 || keycopy[1] == 96 || (strlen(keycopy) > 2 && strcmp(keycopy, "^Space") != 0))) || (strlen(keycopy) > 3 && strcmp(keycopy, "^Space") != 0 && strcmp(keycopy, "M-Space") != 0)) { -- 2.7.4