Mercurial > vim
comparison src/misc2.c @ 16706:77bcb5055fec v8.1.1355
patch 8.1.1355: obvious mistakes are accepted as valid expressions
commit https://github.com/vim/vim/commit/16e9b85113e0b354ece1cb4f5fcc7866850f3685
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 19 19:59:35 2019 +0200
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Problem: Obvious mistakes are accepted as valid expressions.
Solution: Be more strict about parsing numbers. (Yasuhiro Matsumoto,
closes #3981)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 May 2019 20:00:09 +0200 |
parents | 7e733046db1d |
children | ef00b6bc186b |
comparison
equal
deleted
inserted
replaced
16705:033ac0bfd3ba | 16706:77bcb5055fec |
---|---|
2830 } | 2830 } |
2831 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) | 2831 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) |
2832 bp += 3; /* skip t_xx, xx may be '-' or '>' */ | 2832 bp += 3; /* skip t_xx, xx may be '-' or '>' */ |
2833 else if (STRNICMP(bp, "char-", 5) == 0) | 2833 else if (STRNICMP(bp, "char-", 5) == 0) |
2834 { | 2834 { |
2835 vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0); | 2835 vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE); |
2836 if (l == 0) | |
2837 { | |
2838 emsg(_(e_invarg)); | |
2839 return 0; | |
2840 } | |
2836 bp += l + 5; | 2841 bp += l + 5; |
2837 break; | 2842 break; |
2838 } | 2843 } |
2839 } | 2844 } |
2840 | 2845 |
2862 { | 2867 { |
2863 if (STRNICMP(last_dash + 1, "char-", 5) == 0 | 2868 if (STRNICMP(last_dash + 1, "char-", 5) == 0 |
2864 && VIM_ISDIGIT(last_dash[6])) | 2869 && VIM_ISDIGIT(last_dash[6])) |
2865 { | 2870 { |
2866 /* <Char-123> or <Char-033> or <Char-0x33> */ | 2871 /* <Char-123> or <Char-033> or <Char-0x33> */ |
2867 vim_str2nr(last_dash + 6, NULL, NULL, STR2NR_ALL, NULL, &n, 0); | 2872 vim_str2nr(last_dash + 6, NULL, &l, STR2NR_ALL, NULL, &n, 0, TRUE); |
2873 if (l == 0) | |
2874 { | |
2875 emsg(_(e_invarg)); | |
2876 return 0; | |
2877 } | |
2868 key = (int)n; | 2878 key = (int)n; |
2869 } | 2879 } |
2870 else | 2880 else |
2871 { | 2881 { |
2872 int off = 1; | 2882 int off = 1; |