@@ -552,6 +552,19 @@ static inline bool IsSpecial(std::string scheme) {
552552 return false ;
553553}
554554
555+ // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
556+ static inline bool StartsWithWindowsDriveLetter (const char * p,
557+ const char * end) {
558+ const size_t length = end - p;
559+ return length >= 2 &&
560+ IsWindowsDriveLetter (p[0 ], p[1 ]) &&
561+ (length == 2 ||
562+ p[2 ] == ' /' ||
563+ p[2 ] == ' \\ ' ||
564+ p[2 ] == ' ?' ||
565+ p[2 ] == ' #' );
566+ }
567+
555568static inline int NormalizePort (std::string scheme, int p) {
556569#define XX (name, port ) if (scheme == name && p == port) return -1 ;
557570 SPECIALS (XX);
@@ -1198,6 +1211,7 @@ void URL::Parse(const char* input,
11981211 bool special = (url->flags & URL_FLAGS_SPECIAL);
11991212 bool cannot_be_base;
12001213 const bool special_back_slash = (special && ch == ' \\ ' );
1214+
12011215 switch (state) {
12021216 case kSchemeStart :
12031217 if (IsASCIIAlpha (ch)) {
@@ -1667,13 +1681,7 @@ void URL::Parse(const char* input,
16671681 state = kFragment ;
16681682 break ;
16691683 default :
1670- if ((remaining == 0 ||
1671- !IsWindowsDriveLetter (ch, p[1 ]) ||
1672- (remaining >= 2 &&
1673- p[2 ] != ' /' &&
1674- p[2 ] != ' \\ ' &&
1675- p[2 ] != ' ?' &&
1676- p[2 ] != ' #' ))) {
1684+ if (!StartsWithWindowsDriveLetter (p, end)) {
16771685 if (base->flags & URL_FLAGS_HAS_HOST) {
16781686 url->flags |= URL_FLAGS_HAS_HOST;
16791687 url->host = base->host ;
@@ -1697,7 +1705,8 @@ void URL::Parse(const char* input,
16971705 state = kFileHost ;
16981706 } else {
16991707 if (has_base &&
1700- base->scheme == " file:" ) {
1708+ base->scheme == " file:" &&
1709+ !StartsWithWindowsDriveLetter (p, end)) {
17011710 if (IsNormalizedWindowsDriveLetter (base->path [0 ])) {
17021711 url->flags |= URL_FLAGS_HAS_PATH;
17031712 url->path .push_back (base->path [0 ]);
0 commit comments