41 (
'0' <=
c &&
c <=
'9' ) ||
42 (
'a' <=
c &&
c <=
'z' ) ||
43 (
'A' <=
c &&
c <=
'Z' ) ||
66 (
'0' <=
c &&
c <=
'9' ) ||
67 (
'a' <=
c &&
c <=
'z' ) ||
68 (
'A' <=
c &&
c <=
'Z' ) ||
101 return nullptr != std::strchr(
103 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
104 "abcdefghijklmnopqrstuvwxyz"
126 static constexpr bool
130 (
'0' <=
c &&
c <=
'9' ) ||
131 (
'a' <=
c &&
c <=
'z' ) ||
132 (
'A' <=
c &&
c <=
'Z' ) ||
193 (
'0' <=
c &&
c <=
'9' ) ||
194 (
'a' <=
c &&
c <=
'f' ) ||
195 (
'A' <=
c &&
c <=
'F' );
203 if(
'0' <=
c1 &&
c1 <=
'9' )
213 if(
'0' <=
c2 &&
c2 <=
'9' )
244 const char *
d =
data.data();
258 "next byte from UTF-8 sequence expected at {}" ),
273 "invalid UTF-8 sequence detected at {}" ),
290 "invalid escape sequence at pos {}" ),
301 else if( Traits::ordinary_char(
c ) )
312 "invalid non-escaped char with code {:#02X} at pos: {}" ),
332template<
typename Traits = restinio_default_unescape_traits >
342 [](
auto c ){ return !Traits::ordinary_char(c); } ));
355 if( Traits::ordinary_char(
c ) )
367template<
typename Traits = restinio_default_unescape_traits >
375 auto r = impl::do_unescape_percent_encoding<Traits>(
396template<
typename Traits = restinio_default_unescape_traits >
404 auto r = impl::do_unescape_percent_encoding<Traits>(
408 return make_unexpected( std::move(
r.error()) );
413template<
typename Traits = restinio_default_unescape_traits >
421 auto r = impl::do_unescape_percent_encoding<Traits>(
445template<
typename Traits = restinio_default_unescape_traits >
453 auto r = impl::do_unescape_percent_encoding<Traits>(
460 return make_unexpected( std::move(
r.error()) );
467namespace uri_normalization
470namespace unreserved_chars
518 const char *
d =
what.data();
531 "next byte from UTF-8 sequence expected at {}" ),
543 is_hexdigit(
d[ 1 ] ) && is_hexdigit(
d[ 2 ] ) )
545 const char ch = extract_escaped_char(
d[ 1 ],
d[ 2 ] );
550 "invalid UTF-8 sequence detected at {}" ),
565 const char ascii_char =
static_cast<char>(symbol);
659 [&
dest](
char ch )
noexcept {
Exception class for all exceptions thrown by RESTinio.
Type that indicates a failure of unescaping of percent-encoded symbols.
const std::string & description() const noexcept
Get a reference to the description of the failure.
std::string giveout_description() noexcept
Get out the value of the description of the failure.
std::string m_description
Description of a failure.
unescape_percent_encoding_failure_t(std::string description)
Helper class for checking UTF-8 byte sequence during parsing URI or incoming byte stream.
A special wrapper around fmtlib include files.
#define RESTINIO_FMT_FORMAT_STRING(s)
char extract_escaped_char(char c1, char c2)
expected_t< unescape_percent_encoding_success_t, unescape_percent_encoding_failure_t > do_unescape_percent_encoding(const string_view_t data, Chars_Collector &&collector)
The actual implementation of unescape-percent-encoding procedure.
constexpr bool is_unreserved_char(const char ch) noexcept
Is this symbol a part of unreserved set?
void run_normalization_algo(string_view_t what, One_Byte_Handler &&one_byte_handler, Three_Byte_Handler &&three_byte_handler)
Internal helper to perform the main logic of enumeration of symbols in URI.
std::size_t estimate_required_capacity(string_view_t what)
Calculate the size of a buffer to hold normalized value of a URI.
void normalize_to(string_view_t what, char *dest)
Perform normalization of URI value.
std::string escape_percent_encoding(const string_view_t data)
Percent encoding.
std::string unescape_percent_encoding(const string_view_t data)
std::size_t inplace_unescape_percent_encoding(char *data, std::size_t size)
expected_t< std::size_t, unescape_percent_encoding_failure_t > try_inplace_unescape_percent_encoding(char *data, std::size_t size)
Helper function for unescaping percent-encoded string inplace.
expected_t< std::string, unescape_percent_encoding_failure_t > try_unescape_percent_encoding(const string_view_t data)
Helper function for unescaping percent-encoded string.
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
std::string_view string_view_t
nonstd::expected< T, E > expected_t
The traits for escaping and unexcaping symbols in JavaScript-compatible mode.
static constexpr bool ordinary_char(char c) noexcept
Traits for escaping and unescaping symbols in a query string in very relaxed mode.
static bool ordinary_char(char c) noexcept
The default traits for escaping and unexcaping symbols in a query string.
static constexpr bool ordinary_char(char c) noexcept
Type that indicates that unescaping of percent-encoded symbols completed successfully.
An implementation of checker for UTF-8 sequences.