Patch 8.2.3153

3 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 11, 2021, 3:51:54 PM7/11/21
to vim...@googlegroups.com

Patch 8.2.3153
Problem: URLs with a dash in the scheme are not recognized.
Solution: Allow for a scheme with a dash, but not at the start or end.
(Tsuyoshi CHO, closes #8299)
Files: src/misc1.c, src/testdir/test_buffer.vim


*** ../vim-8.2.3152/src/misc1.c 2021-07-10 21:28:55.327050110 +0200
--- src/misc1.c 2021-07-11 21:47:58.001666330 +0200
***************
*** 2600,2607 ****
}

/*
! * Check if "fname" starts with "name://". Return URL_SLASH if it does.
! * Return URL_BACKSLASH for "name:\\".
* Return zero otherwise.
*/
int
--- 2600,2607 ----
}

/*
! * Check if "fname" starts with "name://" or "name:\\".
! * Return URL_SLASH for "name://", URL_BACKSLASH for "name:\\".
* Return zero otherwise.
*/
int
***************
*** 2609,2615 ****
{
char_u *p;

! for (p = fname; isalpha(*p); ++p)
;
return path_is_url(p);
}
--- 2609,2630 ----
{
char_u *p;

! // We accept alphabetic characters and a dash in scheme part.
! // RFC 3986 allows for more, but it increases the risk of matching
! // non-URL text.
!
! // first character must be alpha
! if (!isalpha(*fname))
! return 0;
!
! // check body: alpha or dash
! for (p = fname; (isalpha(*p) || (*p == '-')); ++p)
;
+
+ // check last char is not a dash
+ if (p[-1] == '-')
+ return 0;
+
+ // "://" or ":\\" must follow
return path_is_url(p);
}
*** ../vim-8.2.3152/src/testdir/test_buffer.vim 2021-05-19 17:15:00.825866111 +0200
--- src/testdir/test_buffer.vim 2021-07-11 21:50:25.509366909 +0200
***************
*** 381,386 ****
--- 381,415 ----
call assert_equal('OtherBuffer', bufname())
endfunc

+ " Test for buffer match URL(scheme) check
+ " scheme is alpha and inner hyphen only.
+ func Test_buffer_scheme()
+ CheckMSWindows
+
+ set noshellslash
+ %bwipe!
+ let bufnames = [
+ \ #{id: 'b0', name: 'test://xyz/foo/b0' , match: 1},
+ \ #{id: 'b1', name: 'test+abc://xyz/foo/b1', match: 0},
+ \ #{id: 'b2', name: 'test_abc://xyz/foo/b2', match: 0},
+ \ #{id: 'b3', name: 'test-abc://xyz/foo/b3', match: 1},
+ \ #{id: 'b4', name: '-test://xyz/foo/b4' , match: 0},
+ \ #{id: 'b5', name: 'test-://xyz/foo/b5' , match: 0},
+ \]
+ for buf in bufnames
+ new `=buf.name`
+ if buf.match
+ call assert_equal(buf.name, getbufinfo(buf.id)[0].name)
+ else
+ " slashes will have become backslashes
+ call assert_notequal(buf.name, getbufinfo(buf.id)[0].name)
+ endif
+ bwipe
+ endfor
+
+ set shellslash&
+ endfunc
+
" Test for the 'maxmem' and 'maxmemtot' options
func Test_buffer_maxmem()
" use 1KB per buffer and 2KB for all the buffers
*** ../vim-8.2.3152/src/version.c 2021-07-11 20:58:54.788028521 +0200
--- src/version.c 2021-07-11 21:50:34.121349619 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3153,
/**/

--
hundred-and-one symptoms of being an internet addict:
122. You ask if the Netaholics Anonymous t-shirt you ordered can be
sent to you via e-mail.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages