95.83% Lines (23/24)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 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 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP | 11 | #ifndef BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP | |||||
| 12 | #define BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP | 12 | #define BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/detail/config.hpp> | 14 | #include <boost/url/detail/config.hpp> | |||||
| 15 | #include <boost/url/rfc/pct_encoded_rule.hpp> | 15 | #include <boost/url/rfc/pct_encoded_rule.hpp> | |||||
| 16 | #include <boost/url/rfc/sub_delim_chars.hpp> | 16 | #include <boost/url/rfc/sub_delim_chars.hpp> | |||||
| 17 | #include <boost/url/rfc/unreserved_chars.hpp> | 17 | #include <boost/url/rfc/unreserved_chars.hpp> | |||||
| 18 | #include <boost/url/grammar/parse.hpp> | 18 | #include <boost/url/grammar/parse.hpp> | |||||
| 19 | 19 | |||||||
| 20 | namespace boost { | 20 | namespace boost { | |||||
| 21 | namespace urls { | 21 | namespace urls { | |||||
| 22 | namespace detail { | 22 | namespace detail { | |||||
| 23 | 23 | |||||||
| 24 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | 24 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | |||||
| 25 | auto | 25 | auto | |||||
| HITCBC | 26 | 6556 | userinfo_rule_t:: | 26 | 6556 | userinfo_rule_t:: | ||
| 27 | parse( | 27 | parse( | |||||
| 28 | char const*& it, | 28 | char const*& it, | |||||
| 29 | char const* const end | 29 | char const* const end | |||||
| 30 | ) const noexcept -> | 30 | ) const noexcept -> | |||||
| 31 | system::result<value_type> | 31 | system::result<value_type> | |||||
| 32 | { | 32 | { | |||||
| HITCBC | 33 | 6556 | constexpr auto uchars = | 33 | 6556 | constexpr auto uchars = | ||
| 34 | unreserved_chars + | 34 | unreserved_chars + | |||||
| 35 | sub_delim_chars; | 35 | sub_delim_chars; | |||||
| HITCBC | 36 | 6556 | constexpr auto pwchars = | 36 | 6556 | constexpr auto pwchars = | ||
| 37 | uchars + ':'; | 37 | uchars + ':'; | |||||
| 38 | 38 | |||||||
| HITCBC | 39 | 6556 | value_type t; | 39 | 6556 | value_type t; | ||
| 40 | 40 | |||||||
| 41 | // user | 41 | // user | |||||
| HITCBC | 42 | 6556 | auto rv = grammar::parse( | 42 | 6556 | auto rv = grammar::parse( | ||
| HITCBC | 43 | 6556 | it, end, pct_encoded_rule( | 43 | 6556 | it, end, pct_encoded_rule( | ||
| HITCBC | 44 | 6556 | grammar::ref(uchars))); | 44 | 6556 | grammar::ref(uchars))); | ||
| HITCBC | 45 | 6556 | if(! rv) | 45 | 6556 | if(! rv) | ||
| HITCBC | 46 | 8 | return rv.error(); | 46 | 8 | return rv.error(); | ||
| HITCBC | 47 | 6548 | t.user = *rv; | 47 | 6548 | t.user = *rv; | ||
| 48 | 48 | |||||||
| 49 | // ':' | 49 | // ':' | |||||
| HITCBC | 50 | 6548 | if( it == end || | 50 | 6548 | if( it == end || | ||
| HITCBC | 51 | 6249 | *it != ':') | 51 | 6249 | *it != ':') | ||
| 52 | { | 52 | { | |||||
| HITCBC | 53 | 6012 | t.has_password = false; | 53 | 6012 | t.has_password = false; | ||
| HITCBC | 54 | 6012 | t.password = {}; | 54 | 6012 | t.password = {}; | ||
| HITCBC | 55 | 6012 | return t; | 55 | 6012 | return t; | ||
| 56 | } | 56 | } | |||||
| HITCBC | 57 | 536 | ++it; | 57 | 536 | ++it; | ||
| 58 | 58 | |||||||
| 59 | // pass | 59 | // pass | |||||
| HITCBC | 60 | 536 | rv = grammar::parse( | 60 | 536 | rv = grammar::parse( | ||
| HITCBC | 61 | 536 | it, end, pct_encoded_rule( | 61 | 536 | it, end, pct_encoded_rule( | ||
| HITCBC | 62 | 536 | grammar::ref(pwchars))); | 62 | 536 | grammar::ref(pwchars))); | ||
| HITCBC | 63 | 536 | if(! rv) | 63 | 536 | if(! rv) | ||
| MISUBC | 64 | ✗ | return rv.error(); | 64 | ✗ | return rv.error(); | ||
| 65 | 65 | |||||||
| HITCBC | 66 | 536 | t.has_password = true; | 66 | 536 | t.has_password = true; | ||
| HITCBC | 67 | 536 | t.password = *rv; | 67 | 536 | t.password = *rv; | ||
| HITCBC | 68 | 536 | return t; | 68 | 536 | return t; | ||
| 69 | } | 69 | } | |||||
| 70 | 70 | |||||||
| 71 | } // detail | 71 | } // detail | |||||
| 72 | } // urls | 72 | } // urls | |||||
| 73 | } // boost | 73 | } // boost | |||||
| 74 | 74 | |||||||
| 75 | 75 | |||||||
| 76 | #endif | 76 | #endif | |||||