diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-29 10:08:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-29 10:08:37 +0000 |
commit | 1594afa256a047011011cf29e4f04fa1c5e5fc3a (patch) | |
tree | 3ea5b241560e3f767e36f81119a8b571ab986330 /usr.bin/tmux/cmd-parse.y | |
parent | 62a3c4800f827a90c96b09156d122ef7a963ac6c (diff) |
Support \ooo escapes, from Avi Halachmi.
Diffstat (limited to 'usr.bin/tmux/cmd-parse.y')
-rw-r--r-- | usr.bin/tmux/cmd-parse.y | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index 0180a0fe125..b68289926fa 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.6 2019/05/27 12:16:27 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.7 2019/05/29 10:08:36 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1083,12 +1083,34 @@ error: static int yylex_token_escape(char **buf, size_t *len) { - int ch, type; + int ch, type, o2, o3; u_int size, i, tmp; char s[9]; struct utf8_data ud; - switch (ch = yylex_getc()) { + ch = yylex_getc(); + + if (ch >= '4' && ch <= '7') { + yyerror("invalid octal escape"); + return (0); + } + if (ch >= '0' && ch <= '3') { + o2 = yylex_getc(); + if (o2 >= '0' && o2 <= '7') { + o3 = yylex_getc(); + if (o3 >= '0' && o3 <= '7') { + ch = 64 * (ch - '0') + + 8 * (o2 - '0') + + (o3 - '0'); + yylex_append1(buf, len, ch); + return (1); + } + } + yyerror("invalid octal escape"); + return (0); + } + + switch (ch) { case EOF: return (0); case 'e': |