MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / cookieDomainMatches

Function cookieDomainMatches

Libraries/HttpClient/HttpClientSession.cpp:436–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436static bool cookieDomainMatches(const SC::HttpClientSessionCookie& cookie, SC::StringSpan host)
437{
438 if ((cookie.flags & SC::HttpClientSessionCookie::DomainCookie) == 0)
439 {
440 return sessionAsciiEqualsIgnoreCase(cookie.domain, host);
441 }
442
443 if (sessionAsciiEqualsIgnoreCase(cookie.domain, host))
444 {
445 return true;
446 }
447
448 if (host.sizeInBytes() <= cookie.domain.sizeInBytes() + 1)
449 {
450 return false;
451 }
452 const SC::Span<const char> hostBytes = host.toCharSpan();
453 const size_t offset = host.sizeInBytes() - cookie.domain.sizeInBytes();
454 if (hostBytes[offset - 1] != '.')
455 {
456 return false;
457 }
458 return sessionAsciiEqualsIgnoreCase(
459 {{hostBytes.data() + offset, cookie.domain.sizeInBytes()}, false, SC::StringEncoding::Ascii}, cookie.domain);
460}
461
462static bool cookieDomainAttributeMatches(SC::StringSpan domain, SC::StringSpan host)
463{

Callers 1

appendMatchingCookiesMethod · 0.85

Calls 3

sizeInBytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected