| 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 | 574 | implementation_defined::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 33 times.
✓ Branch 1 taken 541 times.
|
574 | if(it == end) |
| 29 | { | ||
| 30 | // empty string = 1 param | ||
| 31 | 33 | core::string_view str(it, 0); | |
| 32 | 33 | return params_encoded_view( | |
| 33 | 66 | detail::query_ref(str, 0, 1)); | |
| 34 | } | ||
| 35 | 541 | auto const it0 = it; | |
| 36 | 541 | std::size_t dn = 0; | |
| 37 | 541 | std::size_t nparam = 1; | |
| 38 |
2/2✓ Branch 0 taken 6721 times.
✓ Branch 1 taken 363 times.
|
7084 | while(it != end) |
| 39 | { | ||
| 40 |
2/2✓ Branch 0 taken 462 times.
✓ Branch 1 taken 6259 times.
|
6721 | if(*it == '&') |
| 41 | { | ||
| 42 | 462 | ++nparam; | |
| 43 | 462 | ++it; | |
| 44 | 462 | continue; | |
| 45 | } | ||
| 46 |
2/2✓ Branch 1 taken 5952 times.
✓ Branch 2 taken 307 times.
|
6259 | if(detail::query_chars(*it)) |
| 47 | { | ||
| 48 | 5952 | ++it; | |
| 49 | 5952 | continue; | |
| 50 | } | ||
| 51 |
2/2✓ Branch 0 taken 141 times.
✓ Branch 1 taken 166 times.
|
307 | if(*it == '%') |
| 52 | { | ||
| 53 |
4/4✓ Branch 0 taken 132 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 129 times.
|
273 | if(end - it < 3 || |
| 54 |
2/2✓ Branch 1 taken 131 times.
✓ Branch 2 taken 1 times.
|
132 | (!grammar::hexdig_chars(it[1]) || |
| 55 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 129 times.
|
131 | !grammar::hexdig_chars(it[2]))) |
| 56 | { | ||
| 57 | // missing valid HEXDIG | ||
| 58 | 12 | break; | |
| 59 | } | ||
| 60 | 129 | it += 3; | |
| 61 | 129 | dn += 2; | |
| 62 | 129 | continue; | |
| 63 | } | ||
| 64 | // got reserved character | ||
| 65 | 166 | break; | |
| 66 | } | ||
| 67 | 541 | std::size_t const n(it - it0); | |
| 68 | 541 | core::string_view str(it0, n); | |
| 69 | 541 | return params_encoded_view( | |
| 70 | 1082 | detail::query_ref( | |
| 71 | 541 | str, n - dn, nparam)); | |
| 72 | } | ||
| 73 | |||
| 74 | } // urls | ||
| 75 | } // boost | ||
| 76 | |||
| 77 |