Changeset 206157 in webkit
- Timestamp:
- Sep 20, 2016 11:27:37 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206156 r206157 1 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 3 Fix Windows file URL quirks in URLParser 4 https://bugs.webkit.org/show_bug.cgi?id=162303 5 6 Reviewed by Tim Horton. 7 8 Windows file urls allow c:\ and c|\ to have the same meaning, but when serialized they should both be c:/. 9 This is now standardized to allow cross-platform uniform behavior of URLs. 10 11 Covered by new API tests and progress on web platform tests when URLParser is enabled. 12 13 * platform/URLParser.cpp: 14 (WebCore::incrementIteratorSkippingTabAndNewLine): 15 (WebCore::isWindowsDriveLetter): 16 (WebCore::checkWindowsDriveLetter): 17 (WebCore::shouldCopyFileURL): 18 (WebCore::URLParser::parseSerializedURL): 19 (WebCore::URLParser::parse): 20 1 21 2016-09-20 Said Abou-Hallawa <sabouhallawa@apple.com> 2 22 -
trunk/Source/WebCore/platform/URLParser.cpp
r206126 r206157 394 394 template<typename CharacterType> inline static bool isSlashQuestionOrHash(CharacterType character) { return character <= '\\' && characterClassTable[character] & SlashQuestionOrHash; } 395 395 static bool shouldPercentEncodeQueryByte(uint8_t byte) { return characterClassTable[byte] & QueryPercent; } 396 397 template<typename CharacterType> 396 397 template<bool serialized, typename CharacterType> 398 void incrementIteratorSkippingTabAndNewLine(CodePointIterator<CharacterType>& iterator) 399 { 400 ++iterator; 401 while (!serialized && !iterator.atEnd() && isTabOrNewline(*iterator)) 402 ++iterator; 403 } 404 405 template<bool serialized, typename CharacterType> 398 406 inline static bool isWindowsDriveLetter(CodePointIterator<CharacterType> iterator) 399 407 { 400 408 if (iterator.atEnd() || !isASCIIAlpha(*iterator)) 401 409 return false; 402 ++iterator;410 incrementIteratorSkippingTabAndNewLine<serialized>(iterator); 403 411 if (iterator.atEnd()) 404 412 return false; … … 413 421 } 414 422 415 template<typename CharacterType> 423 template<bool serialized, typename CharacterType> 424 inline static void checkWindowsDriveLetter(CodePointIterator<CharacterType>& iterator, Vector<LChar>& asciiBuffer) 425 { 426 if (isWindowsDriveLetter<serialized>(iterator)) { 427 asciiBuffer.reserveCapacity(asciiBuffer.size() + 2); 428 asciiBuffer.uncheckedAppend(*iterator); 429 incrementIteratorSkippingTabAndNewLine<serialized>(iterator); 430 ASSERT(!iterator.atEnd()); 431 ASSERT(*iterator == ':' || *iterator == '|'); 432 asciiBuffer.uncheckedAppend(':'); 433 incrementIteratorSkippingTabAndNewLine<serialized>(iterator); 434 } 435 } 436 437 template<bool serialized, typename CharacterType> 416 438 inline static bool shouldCopyFileURL(CodePointIterator<CharacterType> iterator) 417 439 { 418 if ( isWindowsDriveLetter(iterator))440 if (!isWindowsDriveLetter<serialized>(iterator)) 419 441 return true; 420 442 if (iterator.atEnd()) 421 443 return false; 422 ++iterator;444 incrementIteratorSkippingTabAndNewLine<serialized>(iterator); 423 445 if (iterator.atEnd()) 424 446 return true; 425 ++iterator;447 incrementIteratorSkippingTabAndNewLine<serialized>(iterator); 426 448 if (iterator.atEnd()) 427 449 return true; … … 890 912 return parse<serialized>(input.characters8(), input.length(), { }, UTF8Encoding()); 891 913 return parse<serialized>(input.characters16(), input.length(), { }, UTF8Encoding()); 892 }893 894 template<bool serialized, typename CharacterType>895 void incrementIteratorSkippingTabAndNewLine(CodePointIterator<CharacterType>& iterator)896 {897 ++iterator;898 while (!serialized && !iterator.atEnd() && isTabOrNewline(*iterator))899 ++iterator;900 914 } 901 915 … … 1205 1219 break; 1206 1220 default: 1207 if (!base.isNull() && base.protocolIs("file") && shouldCopyFileURL (c))1221 if (!base.isNull() && base.protocolIs("file") && shouldCopyFileURL<serialized>(c)) 1208 1222 copyURLPartsUntil(base, URLPart::PathAfterLastSlash); 1209 1223 else { … … 1215 1229 m_url.m_portEnd = m_url.m_userStart; 1216 1230 m_url.m_pathAfterLastSlash = m_url.m_userStart + 1; 1231 checkWindowsDriveLetter<serialized>(c, m_asciiBuffer); 1217 1232 } 1218 1233 state = State::Path; … … 1239 1254 if (basePath.length() >= 2) { 1240 1255 bool windowsQuirk = basePath.is8Bit() 1241 ? isWindowsDriveLetter (CodePointIterator<LChar>(basePath.characters8(), basePath.characters8() + basePath.length()))1242 : isWindowsDriveLetter (CodePointIterator<UChar>(basePath.characters16(), basePath.characters16() + basePath.length()));1256 ? isWindowsDriveLetter<serialized>(CodePointIterator<LChar>(basePath.characters8(), basePath.characters8() + basePath.length())) 1257 : isWindowsDriveLetter<serialized>(CodePointIterator<UChar>(basePath.characters16(), basePath.characters16() + basePath.length())); 1243 1258 if (windowsQuirk) { 1244 1259 m_asciiBuffer.append(basePath[0]); … … 1246 1261 } 1247 1262 } 1248 state = State::Path;1249 break;1250 1263 } 1251 1264 m_asciiBuffer.append("//", 2); … … 1256 1269 m_url.m_portEnd = m_url.m_userStart; 1257 1270 m_url.m_pathAfterLastSlash = m_url.m_userStart + 1; 1271 checkWindowsDriveLetter<serialized>(c, m_asciiBuffer); 1258 1272 state = State::Path; 1259 1273 break; -
trunk/Tools/ChangeLog
r206154 r206157 1 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 3 Fix Windows file URL quirks in URLParser 4 https://bugs.webkit.org/show_bug.cgi?id=162303 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebCore/URLParser.cpp: 9 (TestWebKitAPI::TEST_F): 10 1 11 2016-09-20 Filip Pizlo <fpizlo@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r206126 r206157 527 527 {"http", "", "", "123.234.0.12", 0, "/", "", "", "http://123.234.0.12/"}, 528 528 {"http", "", "", "123.234.12", 0, "/", "", "", "http://123.234.12/"}); 529 checkRelativeURLDifferences("file:c:\\foo\\bar.html", "file:///tmp/mock/path", 530 {"file", "", "", "", 0, "/c:/foo/bar.html", "", "", "file:///c:/foo/bar.html"}, 531 {"file", "", "", "", 0, "/tmp/mock/c:/foo/bar.html", "", "", "file:///tmp/mock/c:/foo/bar.html"}); 532 checkRelativeURLDifferences(" File:c|////foo\\bar.html", "file:///tmp/mock/path", 533 {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, 534 {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); 535 checkRelativeURLDifferences(" Fil\t\n\te\n\t\n:\t\n\tc\t\n\t|\n\t\n/\t\n\t/\n\t\n//foo\\bar.html", "file:///tmp/mock/path", 536 {"file", "", "", "", 0, "/c:////foo/bar.html", "", "", "file:///c:////foo/bar.html"}, 537 {"file", "", "", "", 0, "/tmp/mock/c|////foo/bar.html", "", "", "file:///tmp/mock/c|////foo/bar.html"}); 538 checkRelativeURLDifferences("C|/foo/bar", "file:///tmp/mock/path", 539 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, 540 {"file", "", "", "", 0, "/tmp/mock/C|/foo/bar", "", "", "file:///tmp/mock/C|/foo/bar"}); 541 checkRelativeURLDifferences("/C|/foo/bar", "file:///tmp/mock/path", 542 {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"}, 543 {"file", "", "", "", 0, "/C|/foo/bar", "", "", "file:///C|/foo/bar"}); 529 544 } 530 545
Note: See TracChangeset
for help on using the changeset viewer.