Mercurial > vim
comparison src/window.c @ 13103:788d01164bb2 v8.0.1426
patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
commit https://github.com/vim/vim/commit/9e3dfc650190e96739abc004eb9948afa68136b4
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 25 14:29:18 2017 +0100
patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Problem: "gf" and <cfile> don't accept ? and & in URL. (Dmitrii Tcyganok)
Solution: Check for a URL and allow for extra characters. (closes https://github.com/vim/vim/issues/2493)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 25 Dec 2017 14:30:06 +0100 |
parents | dd734ee3e2fe |
children | 20fb8c711050 |
comparison
equal
deleted
inserted
replaced
13102:3bbac77b916b | 13103:788d01164bb2 |
---|---|
6079 return NULL; | 6079 return NULL; |
6080 return find_file_name_in_path(ptr, len, options, | 6080 return find_file_name_in_path(ptr, len, options, |
6081 count, curbuf->b_ffname); | 6081 count, curbuf->b_ffname); |
6082 } | 6082 } |
6083 return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); | 6083 return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); |
6084 | |
6085 } | 6084 } |
6086 | 6085 |
6087 /* | 6086 /* |
6088 * Return the file name under or after the cursor. | 6087 * Return the file name under or after the cursor. |
6089 * | 6088 * |
6118 char_u *rel_fname, /* file we are searching relative to */ | 6117 char_u *rel_fname, /* file we are searching relative to */ |
6119 linenr_T *file_lnum) /* line number after the file name */ | 6118 linenr_T *file_lnum) /* line number after the file name */ |
6120 { | 6119 { |
6121 char_u *ptr; | 6120 char_u *ptr; |
6122 int len; | 6121 int len; |
6122 int in_type = TRUE; | |
6123 int is_url = FALSE; | |
6123 | 6124 |
6124 /* | 6125 /* |
6125 * search forward for what could be the start of a file name | 6126 * search forward for what could be the start of a file name |
6126 */ | 6127 */ |
6127 ptr = line + col; | 6128 ptr = line + col; |
6156 * Search forward for the last char of the file name. | 6157 * Search forward for the last char of the file name. |
6157 * Also allow "://" when ':' is not in 'isfname'. | 6158 * Also allow "://" when ':' is not in 'isfname'. |
6158 */ | 6159 */ |
6159 len = 0; | 6160 len = 0; |
6160 while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') | 6161 while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') |
6161 || ((options & FNAME_HYP) && path_is_url(ptr + len))) | 6162 || ((options & FNAME_HYP) && path_is_url(ptr + len)) |
6162 { | 6163 || (is_url && vim_strchr((char_u *)"?&=", ptr[len]) != NULL)) |
6164 { | |
6165 /* After type:// we also include ?, & and = as valid characters, so that | |
6166 * http://google.com?q=this&that=ok works. */ | |
6167 if ((ptr[len] >= 'A' && ptr[len] <= 'Z') || (ptr[len] >= 'a' && ptr[len] <= 'z')) | |
6168 { | |
6169 if (in_type && path_is_url(ptr + len + 1)) | |
6170 is_url = TRUE; | |
6171 } | |
6172 else | |
6173 in_type = FALSE; | |
6174 | |
6163 if (ptr[len] == '\\') | 6175 if (ptr[len] == '\\') |
6164 /* Skip over the "\" in "\ ". */ | 6176 /* Skip over the "\" in "\ ". */ |
6165 ++len; | 6177 ++len; |
6166 #ifdef FEAT_MBYTE | 6178 #ifdef FEAT_MBYTE |
6167 if (has_mbyte) | 6179 if (has_mbyte) |