| 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 | |||
| 11 | #include <boost/url/detail/config.hpp> | ||
| 12 | #include "userinfo_rule.hpp" | ||
| 13 | #include <boost/core/detail/string_view.hpp> | ||
| 14 | #include <boost/url/rfc/pct_encoded_rule.hpp> | ||
| 15 | #include <boost/url/rfc/sub_delim_chars.hpp> | ||
| 16 | #include <boost/url/rfc/unreserved_chars.hpp> | ||
| 17 | #include <boost/url/grammar/parse.hpp> | ||
| 18 | |||
| 19 | namespace boost { | ||
| 20 | namespace urls { | ||
| 21 | namespace detail { | ||
| 22 | |||
| 23 | auto | ||
| 24 | 1833 | userinfo_rule_t:: | |
| 25 | parse( | ||
| 26 | char const*& it, | ||
| 27 | char const* const end | ||
| 28 | ) const noexcept -> | ||
| 29 | system::result<value_type> | ||
| 30 | { | ||
| 31 | static constexpr auto uchars = | ||
| 32 | unreserved_chars + | ||
| 33 | sub_delim_chars; | ||
| 34 | static constexpr auto pwchars = | ||
| 35 | uchars + ':'; | ||
| 36 | |||
| 37 | 1833 | value_type t; | |
| 38 | |||
| 39 | // user | ||
| 40 | 1833 | auto rv = grammar::parse( | |
| 41 | 1833 | it, end, pct_encoded_rule( | |
| 42 | 1833 | grammar::ref(uchars))); | |
| 43 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1825 times.
|
1833 | if(! rv) |
| 44 | 8 | return rv.error(); | |
| 45 | 1825 | t.user = *rv; | |
| 46 | |||
| 47 | // ':' | ||
| 48 |
2/2✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 260 times.
|
1825 | if( it == end || |
| 49 |
2/2✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 418 times.
|
1565 | *it != ':') |
| 50 | { | ||
| 51 | 1407 | t.has_password = false; | |
| 52 | 1407 | t.password = {}; | |
| 53 | 1407 | return t; | |
| 54 | } | ||
| 55 | 418 | ++it; | |
| 56 | |||
| 57 | // pass | ||
| 58 | 418 | rv = grammar::parse( | |
| 59 | 418 | it, end, pct_encoded_rule( | |
| 60 | 418 | grammar::ref(pwchars))); | |
| 61 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
|
418 | if(! rv) |
| 62 | ✗ | return rv.error(); | |
| 63 | |||
| 64 | 418 | t.has_password = true; | |
| 65 | 418 | t.password = *rv; | |
| 66 | 418 | return t; | |
| 67 | } | ||
| 68 | |||
| 69 | } // detail | ||
| 70 | } // urls | ||
| 71 | } // boost | ||
| 72 | |||
| 73 |