| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2 |
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/boostorg/url
|
7 |
|
// Official repository: https://github.com/boostorg/url
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#ifndef BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
|
10 |
|
#ifndef BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
|
| 11 |
|
#define BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
|
11 |
|
#define BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/url/detail/config.hpp>
|
13 |
|
#include <boost/url/detail/config.hpp>
|
| 14 |
|
#include <boost/url/error_types.hpp>
|
14 |
|
#include <boost/url/error_types.hpp>
|
| 15 |
|
#include <boost/url/pct_string_view.hpp>
|
15 |
|
#include <boost/url/pct_string_view.hpp>
|
| 16 |
|
#include <boost/url/grammar/charset.hpp>
|
16 |
|
#include <boost/url/grammar/charset.hpp>
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
|
19 |
|
|
| 20 |
|
namespace implementation_defined {
|
20 |
|
namespace implementation_defined {
|
| 21 |
|
|
21 |
|
|
| 22 |
|
struct pct_encoded_rule_t
|
22 |
|
struct pct_encoded_rule_t
|
| 23 |
|
|
23 |
|
|
| 24 |
|
using value_type = pct_string_view;
|
24 |
|
using value_type = pct_string_view;
|
| 25 |
|
|
25 |
|
|
| 26 |
|
system::result<value_type>
|
26 |
|
system::result<value_type>
|
| 27 |
|
|
27 |
|
|
| 28 |
|
|
28 |
|
|
| 29 |
|
char const* end) const noexcept;
|
29 |
|
char const* end) const noexcept;
|
| 30 |
|
|
30 |
|
|
| 31 |
|
|
31 |
|
|
| 32 |
|
|
32 |
|
|
| 33 |
|
CharSet const& cs) noexcept
|
33 |
|
CharSet const& cs) noexcept
|
| 34 |
|
|
34 |
|
|
| 35 |
|
|
35 |
|
|
| 36 |
|
|
36 |
|
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
|
39 |
|
|
| 40 |
|
|
40 |
|
|
| 41 |
|
} // implementation_defined
|
41 |
|
} // implementation_defined
|
| 42 |
|
|
42 |
|
|
| 43 |
|
/** Rule for a string with percent-encoded escapes
|
43 |
|
/** Rule for a string with percent-encoded escapes
|
| 44 |
|
|
44 |
|
|
| 45 |
|
This function returns a rule which matches
|
45 |
|
This function returns a rule which matches
|
| 46 |
|
a percent-encoded string, permitting characters
|
46 |
|
a percent-encoded string, permitting characters
|
| 47 |
|
in the string which are also in the specified
|
47 |
|
in the string which are also in the specified
|
| 48 |
|
character set to be used unescaped.
|
48 |
|
character set to be used unescaped.
|
| 49 |
|
|
49 |
|
|
| 50 |
|
|
50 |
|
|
| 51 |
|
|
51 |
|
|
| 52 |
|
using value_type = pct_string_view;
|
52 |
|
using value_type = pct_string_view;
|
| 53 |
|
|
53 |
|
|
| 54 |
|
|
54 |
|
|
| 55 |
|
|
55 |
|
|
| 56 |
|
Rules are used with the function @ref grammar::parse.
|
56 |
|
Rules are used with the function @ref grammar::parse.
|
| 57 |
|
|
57 |
|
|
| 58 |
|
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
58 |
|
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
| 59 |
|
|
59 |
|
|
| 60 |
|
system::result< pct_string_view > rv = grammar::parse( "Program%20Files", pct_encoded_rule( pchars ) );
|
60 |
|
system::result< pct_string_view > rv = grammar::parse( "Program%20Files", pct_encoded_rule( pchars ) );
|
| 61 |
|
|
61 |
|
|
| 62 |
|
|
62 |
|
|
| 63 |
|
|
63 |
|
|
| 64 |
|
|
64 |
|
|
| 65 |
|
pct-encoded = "%" HEXDIG HEXDIG
|
65 |
|
pct-encoded = "%" HEXDIG HEXDIG
|
| 66 |
|
|
66 |
|
|
| 67 |
|
|
67 |
|
|
| 68 |
|
@param cs The character set indicating
|
68 |
|
@param cs The character set indicating
|
| 69 |
|
which characters are allowed without escapes.
|
69 |
|
which characters are allowed without escapes.
|
| 70 |
|
Any character which is not in this set must be
|
70 |
|
Any character which is not in this set must be
|
| 71 |
|
escaped, or else parsing returns an error.
|
71 |
|
escaped, or else parsing returns an error.
|
| 72 |
|
|
72 |
|
|
| 73 |
|
|
73 |
|
|
| 74 |
|
|
74 |
|
|
| 75 |
|
|
75 |
|
|
| 76 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-2.1">
|
76 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-2.1">
|
| 77 |
|
2.1. Percent-Encoding (rfc3986)</a>
|
77 |
|
2.1. Percent-Encoding (rfc3986)</a>
|
| 78 |
|
|
78 |
|
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
|
81 |
|
|
| 82 |
|
|
82 |
|
|
| 83 |
|
|
83 |
|
|
| 84 |
|
template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
|
84 |
|
template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
|
| 85 |
|
|
85 |
|
|
| 86 |
|
|
86 |
|
|
| 87 |
|
pct_encoded_rule(CS const& cs) noexcept ->
|
87 |
|
pct_encoded_rule(CS const& cs) noexcept ->
|
| 88 |
|
implementation_defined::pct_encoded_rule_t<CS>
|
88 |
|
implementation_defined::pct_encoded_rule_t<CS>
|
| 89 |
|
|
89 |
|
|
| 90 |
|
// If an error occurs here it means that
|
90 |
|
// If an error occurs here it means that
|
| 91 |
|
// the value of your type does not meet
|
91 |
|
// the value of your type does not meet
|
| 92 |
|
// the requirements. Please check the
|
92 |
|
// the requirements. Please check the
|
| 93 |
|
|
93 |
|
|
| 94 |
|
|
94 |
|
|
| 95 |
|
grammar::is_charset<CS>::value,
|
95 |
|
grammar::is_charset<CS>::value,
|
| 96 |
|
"CharSet requirements not met");
|
96 |
|
"CharSet requirements not met");
|
| 97 |
|
|
97 |
|
|
| 98 |
|
return implementation_defined::pct_encoded_rule_t<CS>(cs);
|
98 |
|
return implementation_defined::pct_encoded_rule_t<CS>(cs);
|
| 99 |
|
|
99 |
|
|
| 100 |
|
|
100 |
|
|
| 101 |
|
|
101 |
|
|
| 102 |
|
|
102 |
|
|
| 103 |
|
|
103 |
|
|
| 104 |
|
#include <boost/url/rfc/impl/pct_encoded_rule.hpp>
|
104 |
|
#include <boost/url/rfc/impl/pct_encoded_rule.hpp>
|
| 105 |
|
|
105 |
|
|
| 106 |
|
|
106 |
|
|