MCPcopy Create free account
hub / github.com/apache/trafficserver / validate_scheme

Function validate_scheme

src/proxy/hdrs/URL.cc:134–154  ·  view source on GitHub ↗

Checks if the (un-well-known) scheme is valid RFC 3986 Section 3.1 These are the valid characters in a scheme: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) return an error if there is another character in the scheme */

Source from the content-addressed store, hash-verified

132 return an error if there is another character in the scheme
133*/
134bool
135validate_scheme(std::string_view scheme)
136{
137 if (scheme.empty()) {
138 return false;
139 }
140
141 if (!ParseRules::is_alpha(scheme[0])) {
142 return false;
143 }
144
145 for (size_t i = 0; i < scheme.size(); ++i) {
146 const char &c = scheme[i];
147
148 if (!(ParseRules::is_alnum(c) != 0 || c == '+' || c == '-' || c == '.')) {
149 return false;
150 }
151 }
152
153 return true;
154}
155
156/*-------------------------------------------------------------------------
157 -------------------------------------------------------------------------*/

Callers 3

url_parse_schemeFunction · 0.85
test_URL.ccFile · 0.85

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected