comparison src/misc1.c @ 25234:34a6db7af738 v8.2.3153

patch 8.2.3153: URLs with a dash in the scheme are not recognized Commit: https://github.com/vim/vim/commit/7b7a118e74d25ff35cd277c2bb5191ae44bb20b2 Author: Tsuyoshi CHO <Tsuyoshi.CHO@Gmail.com> Date: Sun Jul 11 21:51:17 2021 +0200 patch 8.2.3153: URLs with a dash in the scheme are not recognized 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Jul 2021 22:00:05 +0200
parents dc66d0284518
children e2be9f3c5907
comparison
equal deleted inserted replaced
25233:f6a78c6350ff 25234:34a6db7af738
2598 return URL_BACKSLASH; 2598 return URL_BACKSLASH;
2599 return 0; 2599 return 0;
2600 } 2600 }
2601 2601
2602 /* 2602 /*
2603 * Check if "fname" starts with "name://". Return URL_SLASH if it does. 2603 * Check if "fname" starts with "name://" or "name:\\".
2604 * Return URL_BACKSLASH for "name:\\". 2604 * Return URL_SLASH for "name://", URL_BACKSLASH for "name:\\".
2605 * Return zero otherwise. 2605 * Return zero otherwise.
2606 */ 2606 */
2607 int 2607 int
2608 path_with_url(char_u *fname) 2608 path_with_url(char_u *fname)
2609 { 2609 {
2610 char_u *p; 2610 char_u *p;
2611 2611
2612 for (p = fname; isalpha(*p); ++p) 2612 // We accept alphabetic characters and a dash in scheme part.
2613 // RFC 3986 allows for more, but it increases the risk of matching
2614 // non-URL text.
2615
2616 // first character must be alpha
2617 if (!isalpha(*fname))
2618 return 0;
2619
2620 // check body: alpha or dash
2621 for (p = fname; (isalpha(*p) || (*p == '-')); ++p)
2613 ; 2622 ;
2623
2624 // check last char is not a dash
2625 if (p[-1] == '-')
2626 return 0;
2627
2628 // "://" or ":\\" must follow
2614 return path_is_url(p); 2629 return path_is_url(p);
2615 } 2630 }