#include "squid.h"
#include "anyp/Uri.h"
#include "base/Raw.h"
#include "globals.h"
#include "HttpRequest.h"
#include "parser/Tokenizer.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidMath.h"
#include "SquidString.h"
Go to the source code of this file.
Functions | |
static const CharacterSet & | UserInfoChars () |
Characters which are valid within a URI userinfo section. More... | |
void | urlInitialize (void) |
static AnyP::UriScheme | uriParseScheme (Parser::Tokenizer &tok) |
bool | urlAppendDomain (char *host) |
apply append_domain config to the given hostname More... | |
char * | urlCanonicalCleanWithoutRequest (const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme) |
const char * | urlCanonicalFakeHttps (const HttpRequest *request) |
bool | urlIsRelative (const char *url) |
int | matchDomainName (const char *h, const char *d, MatchDomainNameFlags flags) |
bool | urlCheckRequest (const HttpRequest *r) |
Variables | |
static const char | valid_hostname_chars_u [] |
static const char | valid_hostname_chars [] |
Function Documentation
◆ matchDomainName()
int matchDomainName | ( | const char * | host, |
const char * | domain, | ||
MatchDomainNameFlags | flags = mdnNone |
||
) |
matchDomainName() matches a hostname (usually extracted from traffic) with a domainname when mdnNone or mdnRejectSubsubDomains flags are used according to the following rules:
HOST | DOMAIN | mdnNone | mdnRejectSubsubDomains |
---|---|---|---|
foo.com | foo.com | YES | YES |
.foo.com | foo.com | YES | YES |
x.foo.com | foo.com | NO | NO |
foo.com | .foo.com | YES | YES |
.foo.com | .foo.com | YES | YES |
x.foo.com | .foo.com | YES | YES |
.x.foo.com | .foo.com | YES | NO |
y.x.foo.com | .foo.com | YES | NO |
if mdnHonorWildcards flag is set then the matchDomainName() also accepts optional wildcards on hostname:
HOST | DOMAIN | MATCH? |
---|---|---|
*.foo.com | x.foo.com | YES |
*.foo.com | .x.foo.com | YES |
*.foo.com | .foo.com | YES |
*.foo.com | foo.com | NO |
The combination of mdnHonorWildcards and mdnRejectSubsubDomains flags is supported.
- Return values
-
0 means the host matches the domain 1 means the host is greater than the domain -1 means the host is less than the domain
Definition at line 820 of file Uri.cc.
References mdnHonorWildcards, mdnRejectSubsubDomains, and xtolower.
Referenced by aclHostDomainCompare(), check_domain(), ClientRequestContext::hostHeaderVerify(), neighborType(), and urlInitialize().
◆ uriParseScheme()
|
static |
Extract the URI scheme and ':' delimiter from the given input buffer.
Schemes up to 16 characters are accepted.
Governed by RFC 3986 section 3.1
Definition at line 193 of file Uri.cc.
References CharacterSet::ALPHA, SBuf::at(), SBuf::c_str(), CharacterSet::DIGIT, AnyP::UriScheme::FindProtocolType(), Here, and AnyP::PROTO_UNKNOWN.
Referenced by AnyP::Uri::parse().
◆ urlAppendDomain()
bool urlAppendDomain | ( | char * | host | ) |
Appends configured append_domain to hostname, assuming the given buffer is at least SQUIDHOSTNAMELEN bytes long, and that the host FQDN is not a 'dotless' TLD.
- Returns
- false if and only if there is not enough space to append
Definition at line 223 of file Uri.cc.
References SquidConfig::appendDomain, SquidConfig::appendDomainLen, Config, debugs, and SQUIDHOSTNAMELEN.
Referenced by internalRemoteUri(), and AnyP::Uri::parse().
◆ urlCanonicalCleanWithoutRequest()
char * urlCanonicalCleanWithoutRequest | ( | const SBuf & | url, |
const HttpRequestMethod & | method, | ||
const AnyP::UriScheme & | scheme | ||
) |
call HttpRequest::canonicalCleanUrl() instead if you have HttpRequest
- Returns
- a pointer to a local static buffer containing request URI that honors strip_query_terms and %-encodes unsafe URI characters
Definition at line 704 of file Uri.cc.
References Config, LOCAL_ARRAY, MAX_URL, Http::METHOD_CONNECT, SquidConfig::onoff, AnyP::PROTO_URN, rfc1738_escape_unescaped, SQUIDSBUFPH, SQUIDSBUFPRINT, stringHasCntl(), SquidConfig::strip_query_terms, and xstrncpy().
Referenced by HttpRequest::canonicalCleanUrl(), ClientHttpRequest::setErrorUri(), and ClientHttpRequest::setLogUriToRawUri().
◆ urlCanonicalFakeHttps()
const char * urlCanonicalFakeHttps | ( | const HttpRequest * | request | ) |
Yet another alternative to urlCanonical. This one adds the https:// parts to Http::METHOD_CONNECT URL for use in error page outputs. Luckily we can leverage the others instead of duplicating.
Definition at line 733 of file Uri.cc.
References HttpRequest::canonicalCleanUrl(), AnyP::Uri::host(), LOCAL_ARRAY, MAX_URL, HttpRequest::method, Http::METHOD_CONNECT, AnyP::Uri::port(), and HttpRequest::url.
Referenced by ErrorState::compileLegacyCode().
◆ urlCheckRequest()
bool urlCheckRequest | ( | const HttpRequest * | r | ) |
Definition at line 919 of file Uri.cc.
References AnyP::Uri::Asterisk(), HttpHeader::getInt64(), AnyP::Uri::getScheme(), Http::Message::header, Http::MAX_FORWARDS, HttpRequest::method, Http::METHOD_CONNECT, Http::METHOD_GET, Http::METHOD_HEAD, Http::METHOD_OPTIONS, Http::METHOD_PURGE, Http::METHOD_PUT, Http::METHOD_TRACE, AnyP::Uri::path(), AnyP::PROTO_FTP, AnyP::PROTO_HTTP, AnyP::PROTO_HTTPS, AnyP::PROTO_URN, AnyP::PROTO_WAIS, AnyP::PROTO_WHOIS, and HttpRequest::url.
Referenced by clientProcessRequest().
◆ urlInitialize()
void urlInitialize | ( | void | ) |
Definition at line 138 of file Uri.cc.
References assert, debugs, matchDomainName(), mdnHonorWildcards, mdnRejectSubsubDomains, AnyP::PROTO_MAX, and AnyP::ProtocolType_str.
Referenced by mainInitialize().
◆ urlIsRelative()
bool urlIsRelative | ( | const char * | url | ) |
Test if a URL is a relative reference.
Governed by RFC 3986 section 4.2
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty / path-absolute / path-noscheme / path-empty
Definition at line 760 of file Uri.cc.
Referenced by purgeEntriesByHeader().
◆ UserInfoChars()
|
static |
Definition at line 37 of file Uri.cc.
References CharacterSet::ALPHA, and CharacterSet::DIGIT.
Referenced by AnyP::Uri::absolute().
Variable Documentation
◆ valid_hostname_chars
|
static |
Definition at line 28 of file Uri.cc.
Referenced by AnyP::Uri::parse().
◆ valid_hostname_chars_u
|
static |
Definition at line 22 of file Uri.cc.
Referenced by AnyP::Uri::parse().