MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / URIDecode

Function URIDecode

include/util/string_util.hpp:76–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76inline std::size_t URIDecode(const std::string &input, std::string &output)
77{
78 auto src_iter = std::begin(input);
79 const auto src_end = std::end(input);
80 output.resize(input.size() + 1);
81 std::size_t decoded_length = 0;
82 for (decoded_length = 0; src_iter != src_end; ++decoded_length)
83 {
84 if (src_iter[0] == '%' && src_iter[1] && src_iter[2] && isxdigit(src_iter[1]) &&
85 isxdigit(src_iter[2]))
86 {
87 std::string::value_type a = src_iter[1];
88 std::string::value_type b = src_iter[2];
89 a -= src_iter[1] < 58 ? 48 : src_iter[1] < 71 ? 55 : 87;
90 b -= src_iter[2] < 58 ? 48 : src_iter[2] < 71 ? 55 : 87;
91 output[decoded_length] = 16 * a + b;
92 src_iter += 3;
93 continue;
94 }
95 output[decoded_length] = *src_iter++;
96 }
97 output.resize(decoded_length);
98 return decoded_length;
99}
100
101inline std::size_t URIDecodeInPlace(std::string &URI) { return URIDecode(URI, URI); }
102} // namespace osrm::util

Callers 3

HandleRequestMethod · 0.85
URIDecodeInPlaceFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85

Calls 2

resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected