mirror of
https://github.com/boostorg/url.git
synced 2026-02-14 13:12:15 +00:00
pct_encoded_bnf uses CharSet
This commit is contained in:
@@ -35,7 +35,8 @@ struct segment_bnf
|
||||
using bnf::parse;
|
||||
return parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
pchar_mask>{t.v});
|
||||
masked_char_set<
|
||||
pchar_mask>>{t.v});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +58,8 @@ struct segment_nz_bnf
|
||||
auto const start = it;
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
pchar_mask>{t.v}))
|
||||
masked_char_set<
|
||||
pchar_mask>>{t.v}))
|
||||
return false;
|
||||
if(it == start)
|
||||
{
|
||||
@@ -87,8 +89,9 @@ struct segment_nz_nc_bnf
|
||||
auto const start = it;
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
pchar_mask &
|
||||
~colon_char_mask>{t.v}))
|
||||
masked_char_set<
|
||||
pchar_mask &
|
||||
~colon_char_mask>>{t.v}))
|
||||
return false;
|
||||
if(it == start)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,8 @@ struct query_params_bnf
|
||||
// key
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
qpchar_mask>{t.key}))
|
||||
masked_char_set<
|
||||
qpchar_mask>>{t.key}))
|
||||
return false;
|
||||
// "="
|
||||
if(! parse(it, end, ec, '='))
|
||||
@@ -47,8 +48,9 @@ struct query_params_bnf
|
||||
t.value.emplace();
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
qpchar_mask |
|
||||
equals_char_mask>{*t.value}))
|
||||
masked_char_set<
|
||||
qpchar_mask |
|
||||
equals_char_mask>>{*t.value}))
|
||||
{
|
||||
ec = {};
|
||||
t.value.reset();
|
||||
@@ -75,7 +77,8 @@ struct query_params_bnf
|
||||
// key
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
qpchar_mask>{t.key}))
|
||||
masked_char_set<
|
||||
qpchar_mask>>{t.key}))
|
||||
return false;
|
||||
// "="
|
||||
if(! parse(it, end, ec, '='))
|
||||
@@ -89,8 +92,10 @@ struct query_params_bnf
|
||||
t.value.emplace();
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
qpchar_mask |
|
||||
equals_char_mask>{*t.value}))
|
||||
masked_char_set<
|
||||
qpchar_mask |
|
||||
equals_char_mask>>{
|
||||
*t.value}))
|
||||
{
|
||||
ec = {};
|
||||
t.value.reset();
|
||||
|
||||
@@ -28,9 +28,10 @@ parse(
|
||||
using bnf::parse;
|
||||
return parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
pchar_mask |
|
||||
slash_char_mask |
|
||||
question_char_mask>{t.v});
|
||||
masked_char_set<
|
||||
pchar_mask |
|
||||
slash_char_mask |
|
||||
question_char_mask>>{t.v});
|
||||
}
|
||||
|
||||
} // urls
|
||||
|
||||
@@ -73,8 +73,9 @@ parse(
|
||||
pct_encoded_str ns;
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
unsub_char_mask>{
|
||||
t.name_}))
|
||||
masked_char_set<
|
||||
unsub_char_mask>>{
|
||||
t.name_}))
|
||||
{
|
||||
// bad reg-name
|
||||
return false;
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
|
||||
template<std::uint8_t CharMask>
|
||||
template<class CharSet>
|
||||
bool
|
||||
parse(
|
||||
char const*& it,
|
||||
char const* const end,
|
||||
error_code& ec,
|
||||
pct_encoded_bnf<
|
||||
CharMask> const& t) noexcept
|
||||
CharSet> const& t) noexcept
|
||||
{
|
||||
auto const start = it;
|
||||
masked_char_set<CharMask> cs;
|
||||
if(! detail::parse_pct_encoded_impl(
|
||||
it, end, ec, cs,
|
||||
it, end, ec, CharSet{},
|
||||
t.v.decoded_size))
|
||||
return false;
|
||||
t.v.str = string_view(
|
||||
|
||||
@@ -36,11 +36,13 @@ parse(
|
||||
bnf::literal<':'>> colon;
|
||||
if(! parse(it, end, ec,
|
||||
pct_encoded_bnf<
|
||||
unsub_char_mask>{user},
|
||||
masked_char_set<
|
||||
unsub_char_mask>>{user},
|
||||
colon,
|
||||
pct_encoded_bnf<
|
||||
unsub_char_mask |
|
||||
colon_char_mask>{pass}))
|
||||
masked_char_set<
|
||||
unsub_char_mask |
|
||||
colon_char_mask>>{pass}))
|
||||
return false;
|
||||
t.str = string_view(
|
||||
start, it - start);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <boost/url/detail/config.hpp>
|
||||
#include <boost/url/error.hpp>
|
||||
#include <boost/url/string.hpp>
|
||||
#include <boost/url/bnf/detail/char_set.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace urls {
|
||||
@@ -35,21 +37,25 @@ struct pct_encoded_str
|
||||
@see
|
||||
https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
|
||||
*/
|
||||
template<std::uint8_t CharMask>
|
||||
template<class CharSet>
|
||||
struct pct_encoded_bnf
|
||||
{
|
||||
pct_encoded_str& v;
|
||||
|
||||
template<std::uint8_t CharMask_>
|
||||
BOOST_STATIC_ASSERT(
|
||||
bnf::detail::is_char_set_pred<
|
||||
CharSet>::value);
|
||||
|
||||
template<class CharSet_>
|
||||
friend
|
||||
bool
|
||||
parse(
|
||||
char const*& it,
|
||||
char const* const end,
|
||||
error_code& ec,
|
||||
pct_encoded_bnf<CharMask_> const& t) noexcept;
|
||||
pct_encoded_bnf<CharSet_> const& t) noexcept;
|
||||
};
|
||||
|
||||
|
||||
} // urls
|
||||
} // boost
|
||||
|
||||
|
||||
Reference in New Issue
Block a user