From ba06a523681b7e6034b0cac92927b87ee6f2ba8f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 11 Jun 2022 14:13:19 -0700 Subject: [PATCH] ircd::rfc3986: Add public rule abstracting uri_parse construction. --- include/ircd/rfc3986.h | 2 ++ ircd/rfc3986.cc | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/ircd/rfc3986.h b/include/ircd/rfc3986.h index fa855c8d0..200e719ed 100644 --- a/include/ircd/rfc3986.h +++ b/include/ircd/rfc3986.h @@ -146,6 +146,8 @@ namespace ircd::rfc3986::parser extern const rule<> absolute_uri; extern const rule<> uri; extern const rule<> uri_ref; // uri | relative_ref + + extern const rule uri_parse; } #pragma GCC visibility pop diff --git a/ircd/rfc3986.cc b/ircd/rfc3986.cc index 019b59386..df1d4cd71 100644 --- a/ircd/rfc3986.cc +++ b/ircd/rfc3986.cc @@ -398,20 +398,24 @@ BOOST_FUSION_ADAPT_STRUCT ) #pragma GCC visibility pop -ircd::rfc3986::uri::uri(const string_view &input) +decltype(ircd::rfc3986::parser::uri_parse) +ircd::rfc3986::parser::uri_parse { - static const parser::rule rule - { + expect + [ raw[parser::scheme] >> lit("://") >> -raw[parser::userinfo >> lit('@')] >> raw[parser::remote] >> raw[parser::path_abempty] >> -raw[lit('?') >> parser::query] >> -raw[lit('#') >> parser::fragment] - }; + ] +}; +ircd::rfc3986::uri::uri(const string_view &input) +{ const char *start(begin(input)), *const stop(end(input)); - qi::parse(start, stop, eps > rule, *this); + ircd::parse(start, stop, parser::uri_parse, *this); //TODO: XXX Can this go? this->user = rstrip(this->user, '@');