| 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 | 567 | 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 534 times.
|
567 | 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 | 534 | auto const it0 = it; | |
| 36 | 534 | std::size_t dn = 0; | |
| 37 | 534 | std::size_t nparam = 1; | |
| 38 |
2/2✓ Branch 0 taken 6603 times.
✓ Branch 1 taken 356 times.
|
6959 | while(it != end) |
| 39 | { | ||
| 40 |
2/2✓ Branch 0 taken 455 times.
✓ Branch 1 taken 6148 times.
|
6603 | if(*it == '&') |
| 41 | { | ||
| 42 | 455 | ++nparam; | |
| 43 | 455 | ++it; | |
| 44 | 455 | continue; | |
| 45 | } | ||
| 46 |
2/2✓ Branch 1 taken 5876 times.
✓ Branch 2 taken 272 times.
|
6148 | if(detail::query_chars(*it)) |
| 47 | { | ||
| 48 | 5876 | ++it; | |
| 49 | 5876 | continue; | |
| 50 | } | ||
| 51 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 166 times.
|
272 | if(*it == '%') |
| 52 | { | ||
| 53 |
4/4✓ Branch 0 taken 97 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 94 times.
|
203 | if(end - it < 3 || |
| 54 |
2/2✓ Branch 1 taken 96 times.
✓ Branch 2 taken 1 times.
|
97 | (!grammar::hexdig_chars(it[1]) || |
| 55 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 94 times.
|
96 | !grammar::hexdig_chars(it[2]))) |
| 56 | { | ||
| 57 | // missing valid HEXDIG | ||
| 58 | 12 | break; | |
| 59 | } | ||
| 60 | 94 | it += 3; | |
| 61 | 94 | dn += 2; | |
| 62 | 94 | continue; | |
| 63 | } | ||
| 64 | // got reserved character | ||
| 65 | 166 | break; | |
| 66 | } | ||
| 67 | 534 | std::size_t const n(it - it0); | |
| 68 | 534 | core::string_view str(it0, n); | |
| 69 | 534 | return params_encoded_view( | |
| 70 | 1068 | detail::query_ref( | |
| 71 | 534 | str, n - dn, nparam)); | |
| 72 | } | ||
| 73 | |||
| 74 | } // urls | ||
| 75 | } // boost | ||
| 76 | |||
| 77 |