comparison src/misc1.c @ 16277:5ef25fa57f71 v8.1.1143

patch 8.1.1143: may pass weird strings to file name expansion commit https://github.com/vim/vim/commit/8f130eda4747e4a4d68353cdb650f359fd01469b Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 10 22:15:19 2019 +0200 patch 8.1.1143: may pass weird strings to file name expansion Problem: May pass weird strings to file name expansion. Solution: Check for matching characters. Disallow control characters.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Apr 2019 22:30:06 +0200
parents 0761a4c111a7
children 7e733046db1d
comparison
equal deleted inserted replaced
16276:8322ad152939 16277:5ef25fa57f71
6168 static int 6168 static int
6169 has_special_wildchar(char_u *p) 6169 has_special_wildchar(char_u *p)
6170 { 6170 {
6171 for ( ; *p; MB_PTR_ADV(p)) 6171 for ( ; *p; MB_PTR_ADV(p))
6172 { 6172 {
6173 /* Allow for escaping. */ 6173 // Disallow line break characters.
6174 if (*p == '\\' && p[1] != NUL) 6174 if (*p == '\r' || *p == '\n')
6175 break;
6176 // Allow for escaping.
6177 if (*p == '\\' && p[1] != NUL && p[1] != '\r' && p[1] != '\n')
6175 ++p; 6178 ++p;
6176 else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL) 6179 else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL)
6180 {
6181 // A { must be followed by a matching }.
6182 if (*p == '{' && vim_strchr(p, '}') == NULL)
6183 continue;
6184 // A quote and backtick must be followed by another one.
6185 if ((*p == '`' || *p == '\'') && vim_strchr(p, *p) == NULL)
6186 continue;
6177 return TRUE; 6187 return TRUE;
6188 }
6178 } 6189 }
6179 return FALSE; 6190 return FALSE;
6180 } 6191 }
6181 #endif 6192 #endif
6182 6193