////////////////////////////////////////////////////////////////////////// // ValidateDomain // // Returns true if domain from offset onward is a valid cookie domain suffix. // A valid cookie domain suffix contains at least one '.' that is imbedded // e.g. 'a.b' but not '.aa' or '.a.'. We don't check for '..a' as those // host names won't resolve and therefore aren't a liability. // static bool ValidateDomain( FixedString8_128& domain, FixedString8_128::size_type offset ) { FixedString8_128::size_type len = domain.length(); if( offset < FixedString8_128::npos && len > (offset + 1) ) { FixedString8_128::size_type dot = domain.find_first_of( '.', offset + 1 ); if( FixedString8_128::npos != dot && dot < (len-1) ) return true; } return false; }
bool EAWebKitDomainFilter::PathAllowed(const FixedString8_128& path, const FixedString8_128& excludedPaths) const { //We make a copy because we do custom processing on it. FixedString8_128 excludedPathsLocal(excludedPaths); //If the excludedPaths is empty, we assume that all the paths are okay. if(excludedPathsLocal.empty()) return true; //Expect the user to put a ";" at the end and remove it if found. if(excludedPathsLocal.find_last_of(";") == excludedPathsLocal.length()-1) excludedPathsLocal.pop_back(); FixedString8_128 pathShort; FixedString8_128 excludedPath; FixedString8_128::size_type lastDelimPos = 0; FixedString8_128::size_type delimPos = excludedPathsLocal.find_first_of(";"); while(delimPos != FixedString8_128::npos) { excludedPath = excludedPathsLocal.substr(lastDelimPos, delimPos); pathShort = path.substr(0,excludedPath.length()); if(pathShort.comparei(excludedPath)) return false; lastDelimPos = delimPos+1; //Doing this simplifies the code delimPos = excludedPathsLocal.find_first_of(";",lastDelimPos); } excludedPath = excludedPathsLocal.substr(lastDelimPos, excludedPathsLocal.length()); pathShort = path.substr(0,excludedPath.length()); if(pathShort.comparei(excludedPath) == 0) return false; return true; }
void Shutdown() { msLocale.set_capacity(0); msAcceptLanguageHttpHeaderValue.set_capacity(0); msApplicationName.set_capacity(0); msUserAgent.set_capacity(0); }
//replicate the code from the cookie manager. This code can use a little cleanup. But since it is tried and tested, keeping it as is. bool EAWebKitDomainFilter::DomainAllowed(const FixedString8_128& host, const FixedString8_128& allowedDomain) const { int32_t start = host.length() - allowedDomain.length(); if(start >= 0 ) { FixedString8_128 hostDomain = host.substr(start,FixedString8_128::npos); if( hostDomain.comparei(allowedDomain) == 0) { if( (start == 0) || (allowedDomain[0] == '.') || (host[start-1] == '.')) { return true; } } } else if (start == -1) { FixedString8_128 hostWithDot(FixedString8_128::CtorSprintf(),".%s",host.c_str()); if( hostWithDot.comparei(allowedDomain) == 0) return true; } return false; }