| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | ||
| 3 | // | ||
| 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) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/boostorg/url | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_IPP | ||
| 11 | #define BOOST_URL_RFC_DETAIL_IMPL_USERINFO_RULE_IPP | ||
| 12 | |||
| 13 | #include <boost/url/detail/config.hpp> | ||
| 14 | #include <boost/url/rfc/detail/userinfo_rule.hpp> | ||
| 15 | #include <boost/core/detail/string_view.hpp> | ||
| 16 | #include <boost/url/rfc/pct_encoded_rule.hpp> | ||
| 17 | #include <boost/url/rfc/sub_delim_chars.hpp> | ||
| 18 | #include <boost/url/rfc/unreserved_chars.hpp> | ||
| 19 | #include <boost/url/grammar/parse.hpp> | ||
| 20 | |||
| 21 | namespace boost { | ||
| 22 | namespace urls { | ||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | auto | ||
| 26 | 1786 | userinfo_rule_t:: | |
| 27 | parse( | ||
| 28 | char const*& it, | ||
| 29 | char const* const end | ||
| 30 | ) const noexcept -> | ||
| 31 | system::result<value_type> | ||
| 32 | { | ||
| 33 | static constexpr auto uchars = | ||
| 34 | unreserved_chars + | ||
| 35 | sub_delim_chars; | ||
| 36 | static constexpr auto pwchars = | ||
| 37 | uchars + ':'; | ||
| 38 | |||
| 39 | 1786 | value_type t; | |
| 40 | |||
| 41 | // user | ||
| 42 | auto rv = grammar::parse( | ||
| 43 | 1786 | it, end, pct_encoded_rule( | |
| 44 | 1786 | grammar::ref(uchars))); | |
| 45 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1778 times.
|
1786 | if(! rv) |
| 46 | 8 | return rv.error(); | |
| 47 | 1778 | t.user = *rv; | |
| 48 | |||
| 49 | // ':' | ||
| 50 |
2/2✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 257 times.
|
1778 | if( it == end || |
| 51 |
2/2✓ Branch 0 taken 1124 times.
✓ Branch 1 taken 397 times.
|
1521 | *it != ':') |
| 52 | { | ||
| 53 | 1381 | t.has_password = false; | |
| 54 | 1381 | t.password = {}; | |
| 55 | 1381 | return t; | |
| 56 | } | ||
| 57 | 397 | ++it; | |
| 58 | |||
| 59 | // pass | ||
| 60 | rv = grammar::parse( | ||
| 61 | 397 | it, end, pct_encoded_rule( | |
| 62 | 397 | grammar::ref(pwchars))); | |
| 63 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 397 times.
|
397 | if(! rv) |
| 64 | ✗ | return rv.error(); | |
| 65 | |||
| 66 | 397 | t.has_password = true; | |
| 67 | 397 | t.password = *rv; | |
| 68 | 397 | return t; | |
| 69 | } | ||
| 70 | |||
| 71 | } // detail | ||
| 72 | } // urls | ||
| 73 | } // boost | ||
| 74 | |||
| 75 | #endif | ||
| 76 |