| 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 <boost/url/rfc/query_rule.hpp> | ||
| 13 | #include "detail/charsets.hpp" | ||
| 14 | #include <boost/url/error.hpp> | ||
| 15 | #include <boost/url/grammar/hexdig_chars.hpp> | ||
| 16 | |||
| 17 | namespace boost { | ||
| 18 | namespace urls { | ||
| 19 | |||
| 20 | auto | ||
| 21 | 561 | query_rule_t:: | |
| 22 | parse( | ||
| 23 | char const*& it, | ||
| 24 | char const* end | ||
| 25 | ) const noexcept -> | ||
| 26 | system::result<value_type> | ||
| 27 | { | ||
| 28 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 529 times.
|
561 | if(it == end) |
| 29 | { | ||
| 30 | // empty string = 0 params | ||
| 31 | 32 | return params_encoded_view( | |
| 32 | 64 | detail::query_ref( | |
| 33 | 32 | core::string_view(it, 0), 0, 0)); | |
| 34 | } | ||
| 35 | 529 | auto const it0 = it; | |
| 36 | 529 | std::size_t dn = 0; | |
| 37 | 529 | std::size_t nparam = 1; | |
| 38 |
2/2✓ Branch 0 taken 6567 times.
✓ Branch 1 taken 353 times.
|
6920 | while(it != end) |
| 39 | { | ||
| 40 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 6113 times.
|
6567 | if(*it == '&') |
| 41 | { | ||
| 42 | 454 | ++nparam; | |
| 43 | 454 | ++it; | |
| 44 | 454 | continue; | |
| 45 | } | ||
| 46 |
2/2✓ Branch 1 taken 5843 times.
✓ Branch 2 taken 270 times.
|
6113 | if(detail::query_chars(*it)) |
| 47 | { | ||
| 48 | 5843 | ++it; | |
| 49 | 5843 | continue; | |
| 50 | } | ||
| 51 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 164 times.
|
270 | if(*it == '%') |
| 52 | { | ||
| 53 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 97 times.
|
106 | if(end - it < 3) |
| 54 | { | ||
| 55 | // missing HEXDIG | ||
| 56 | 9 | BOOST_URL_RETURN_EC( | |
| 57 | error::missing_pct_hexdig); | ||
| 58 | } | ||
| 59 |
4/4✓ Branch 1 taken 96 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 94 times.
|
193 | if (!grammar::hexdig_chars(it[1]) || |
| 60 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 94 times.
|
96 | !grammar::hexdig_chars(it[2])) |
| 61 | { | ||
| 62 | // expected HEXDIG | ||
| 63 | 3 | BOOST_URL_RETURN_EC( | |
| 64 | error::bad_pct_hexdig); | ||
| 65 | } | ||
| 66 | 94 | it += 3; | |
| 67 | 94 | dn += 2; | |
| 68 | 94 | continue; | |
| 69 | } | ||
| 70 | // got reserved character | ||
| 71 | 164 | break; | |
| 72 | } | ||
| 73 | 517 | std::size_t const n(it - it0); | |
| 74 | 517 | return params_encoded_view( | |
| 75 | 1034 | detail::query_ref( | |
| 76 | core::string_view(it0, n), | ||
| 77 | n - dn, | ||
| 78 | 517 | nparam)); | |
| 79 | } | ||
| 80 | |||
| 81 | } // urls | ||
| 82 | } // boost | ||
| 83 | |||
| 84 |