|
Lines 237-247
URL URLParser::parse(const String& input
Source/WebCore/platform/URLParser.cpp_sec1
|
| 237 |
LOG(URLParser, "Parsing URL <%s> base <%s>", input.utf8().data(), base.string().utf8().data()); |
237 |
LOG(URLParser, "Parsing URL <%s> base <%s>", input.utf8().data(), base.string().utf8().data()); |
| 238 |
m_url = { }; |
238 |
m_url = { }; |
| 239 |
m_buffer.clear(); |
239 |
m_buffer.clear(); |
| 240 |
m_authorityOrHostBuffer.clear(); |
|
|
| 241 |
|
240 |
|
| 242 |
auto codePoints = StringView(input).codePoints(); |
241 |
auto codePoints = StringView(input).codePoints(); |
| 243 |
auto c = codePoints.begin(); |
242 |
auto c = codePoints.begin(); |
| 244 |
auto end = codePoints.end(); |
243 |
auto end = codePoints.end(); |
|
|
244 |
auto authorityOrHostBegin = codePoints.begin(); |
| 245 |
while (c != end && isC0ControlOrSpace(*c)) |
245 |
while (c != end && isC0ControlOrSpace(*c)) |
| 246 |
++c; |
246 |
++c; |
| 247 |
|
247 |
|
|
Lines 371-376
URL URLParser::parse(const String& input
Source/WebCore/platform/URLParser.cpp_sec2
|
| 371 |
if (*c == '/') { |
371 |
if (*c == '/') { |
| 372 |
state = State::AuthorityOrHost; |
372 |
state = State::AuthorityOrHost; |
| 373 |
++c; |
373 |
++c; |
|
|
374 |
authorityOrHostBegin = c; |
| 374 |
} else |
375 |
} else |
| 375 |
state = State::Path; |
376 |
state = State::Path; |
| 376 |
break; |
377 |
break; |
|
Lines 436-465
URL URLParser::parse(const String& input
Source/WebCore/platform/URLParser.cpp_sec3
|
| 436 |
} |
437 |
} |
| 437 |
m_url.m_userStart = m_buffer.length(); |
438 |
m_url.m_userStart = m_buffer.length(); |
| 438 |
state = State::AuthorityOrHost; |
439 |
state = State::AuthorityOrHost; |
|
|
440 |
authorityOrHostBegin = c; |
| 439 |
break; |
441 |
break; |
| 440 |
case State::AuthorityOrHost: |
442 |
case State::AuthorityOrHost: |
| 441 |
LOG_STATE("AuthorityOrHost"); |
443 |
LOG_STATE("AuthorityOrHost"); |
| 442 |
if (*c == '@') { |
444 |
if (*c == '@') { |
| 443 |
authorityEndReached(); |
445 |
parseAuthority(authorityOrHostBegin, c); |
|
|
446 |
++c; |
| 447 |
authorityOrHostBegin = c; |
| 444 |
state = State::Host; |
448 |
state = State::Host; |
| 445 |
} else if (*c == '/' || *c == '?' || *c == '#') { |
449 |
} else if (*c == '/' || *c == '?' || *c == '#') { |
| 446 |
m_url.m_userEnd = m_buffer.length(); |
450 |
m_url.m_userEnd = m_buffer.length(); |
| 447 |
m_url.m_passwordEnd = m_url.m_userEnd; |
451 |
m_url.m_passwordEnd = m_url.m_userEnd; |
| 448 |
hostEndReached(); |
452 |
parseHost(authorityOrHostBegin, c); |
| 449 |
state = State::Path; |
453 |
state = State::Path; |
| 450 |
break; |
454 |
break; |
| 451 |
} else |
455 |
} |
| 452 |
m_authorityOrHostBuffer.append(*c); |
|
|
| 453 |
++c; |
456 |
++c; |
| 454 |
break; |
457 |
break; |
| 455 |
case State::Host: |
458 |
case State::Host: |
| 456 |
LOG_STATE("Host"); |
459 |
LOG_STATE("Host"); |
| 457 |
if (*c == '/' || *c == '?' || *c == '#') { |
460 |
if (*c == '/' || *c == '?' || *c == '#') { |
| 458 |
hostEndReached(); |
461 |
parseHost(authorityOrHostBegin, c); |
| 459 |
state = State::Path; |
462 |
state = State::Path; |
| 460 |
break; |
463 |
break; |
| 461 |
} |
464 |
} |
| 462 |
m_authorityOrHostBuffer.append(*c); |
|
|
| 463 |
++c; |
465 |
++c; |
| 464 |
break; |
466 |
break; |
| 465 |
case State::File: |
467 |
case State::File: |
|
Lines 589-595
URL URLParser::parse(const String& input
Source/WebCore/platform/URLParser.cpp_sec4
|
| 589 |
case State::Host: |
591 |
case State::Host: |
| 590 |
if (state == State::Host) |
592 |
if (state == State::Host) |
| 591 |
LOG_FINAL_STATE("Host"); |
593 |
LOG_FINAL_STATE("Host"); |
| 592 |
hostEndReached(); |
594 |
parseHost(authorityOrHostBegin, end); |
| 593 |
m_buffer.append('/'); |
595 |
m_buffer.append('/'); |
| 594 |
m_url.m_pathEnd = m_url.m_portEnd + 1; |
596 |
m_url.m_pathEnd = m_url.m_portEnd + 1; |
| 595 |
m_url.m_pathAfterLastSlash = m_url.m_pathEnd; |
597 |
m_url.m_pathAfterLastSlash = m_url.m_pathEnd; |
|
Lines 637-647
URL URLParser::parse(const String& input
Source/WebCore/platform/URLParser.cpp_sec5
|
| 637 |
return m_url; |
639 |
return m_url; |
| 638 |
} |
640 |
} |
| 639 |
|
641 |
|
| 640 |
void URLParser::authorityEndReached() |
642 |
void URLParser::parseAuthority(StringView::CodePoints::Iterator& iterator, const StringView::CodePoints::Iterator& end) |
| 641 |
{ |
643 |
{ |
| 642 |
auto codePoints = StringView(m_authorityOrHostBuffer.toString()).codePoints(); |
|
|
| 643 |
auto iterator = codePoints.begin(); |
| 644 |
auto end = codePoints.end(); |
| 645 |
for (; iterator != end; ++iterator) { |
644 |
for (; iterator != end; ++iterator) { |
| 646 |
m_buffer.append(*iterator); |
645 |
m_buffer.append(*iterator); |
| 647 |
if (*iterator == ':') { |
646 |
if (*iterator == ':') { |
|
Lines 654-660
void URLParser::authorityEndReached()
Source/WebCore/platform/URLParser.cpp_sec6
|
| 654 |
m_buffer.append(*iterator); |
653 |
m_buffer.append(*iterator); |
| 655 |
m_url.m_passwordEnd = m_buffer.length(); |
654 |
m_url.m_passwordEnd = m_buffer.length(); |
| 656 |
m_buffer.append('@'); |
655 |
m_buffer.append('@'); |
| 657 |
m_authorityOrHostBuffer.clear(); |
|
|
| 658 |
} |
656 |
} |
| 659 |
|
657 |
|
| 660 |
static void serializeIPv4(uint32_t address, StringBuilder& buffer) |
658 |
static void serializeIPv4(uint32_t address, StringBuilder& buffer) |
|
Lines 925-935
static Optional<std::array<uint16_t, 8>>
Source/WebCore/platform/URLParser.cpp_sec7
|
| 925 |
return address; |
923 |
return address; |
| 926 |
} |
924 |
} |
| 927 |
|
925 |
|
| 928 |
void URLParser::hostEndReached() |
926 |
void URLParser::parseHost(StringView::CodePoints::Iterator& iterator, const StringView::CodePoints::Iterator& end) |
| 929 |
{ |
927 |
{ |
| 930 |
auto codePoints = StringView(m_authorityOrHostBuffer.toString()).codePoints(); |
|
|
| 931 |
auto iterator = codePoints.begin(); |
| 932 |
auto end = codePoints.end(); |
| 933 |
if (iterator == end) |
928 |
if (iterator == end) |
| 934 |
return; |
929 |
return; |
| 935 |
if (*iterator == '[') { |
930 |
if (*iterator == '[') { |
|
Lines 966-972
void URLParser::hostEndReached()
Source/WebCore/platform/URLParser.cpp_sec8
|
| 966 |
} |
961 |
} |
| 967 |
m_url.m_hostEnd = m_buffer.length(); |
962 |
m_url.m_hostEnd = m_buffer.length(); |
| 968 |
m_url.m_portEnd = m_url.m_hostEnd; |
963 |
m_url.m_portEnd = m_url.m_hostEnd; |
| 969 |
m_authorityOrHostBuffer.clear(); |
|
|
| 970 |
} |
964 |
} |
| 971 |
|
965 |
|
| 972 |
bool URLParser::allValuesEqual(const URL& a, const URL& b) |
966 |
bool URLParser::allValuesEqual(const URL& a, const URL& b) |