MCPcopy Create free account
hub / github.com/catboost/catboost / UrlEscape

Function UrlEscape

library/cpp/string_utils/quote/quote.cpp:277–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277char* UrlEscape(char* to, TStringBuf src, bool forceEscape) {
278 for (auto from = src.begin(); from != src.end(); ++from) {
279 const bool escapePercent = (*from == '%') &&
280 (forceEscape || !((std::next(from) != src.end() && IsAsciiHex(*(std::next(from)))
281 && std::next(from, 2) != src.end() && IsAsciiHex(*(std::next(from, 2))))));
282
283 if (escapePercent || (unsigned char)*from <= ' ' || (unsigned char)*from > '~') {
284 *to++ = '%';
285 *to++ = d2x((unsigned char)*from >> 4);
286 *to++ = d2x((unsigned char)*from & 0xF);
287 } else
288 *to++ = *from;
289 }
290
291 *to = 0;
292
293 return to;
294}
295
296void UrlEscape(TString& url, bool forceEscape) {
297 TTempBuf tempBuf(CgiEscapeBufLen(url.size()));

Callers 2

Y_UNIT_TESTFunction · 0.85
UrlEscapeRetFunction · 0.85

Calls 8

IsAsciiHexFunction · 0.85
d2xFunction · 0.85
CgiEscapeBufLenFunction · 0.85
nextFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected