| 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 | #include <boost/url/detail/config.hpp> | ||
| 11 | #include <boost/url/rfc/query_rule.hpp> | ||
| 12 | #include "detail/charsets.hpp" | ||
| 13 | #include <boost/url/error.hpp> | ||
| 14 | #include <boost/url/grammar/hexdig_chars.hpp> | ||
| 15 | |||
| 16 | namespace boost { | ||
| 17 | namespace urls { | ||
| 18 | |||
| 19 | auto | ||
| 20 | 576 | implementation_defined::query_rule_t:: | |
| 21 | parse( | ||
| 22 | char const*& it, | ||
| 23 | char const* end | ||
| 24 | ) const noexcept -> | ||
| 25 | system::result<value_type> | ||
| 26 | { | ||
| 27 |
2/2✓ Branch 0 taken 33 times.
✓ Branch 1 taken 543 times.
|
576 | if(it == end) |
| 28 | { | ||
| 29 | // empty string = 1 param | ||
| 30 | 33 | core::string_view str(it, 0); | |
| 31 | 33 | return params_encoded_view( | |
| 32 | 66 | detail::query_ref(str, 0, 1)); | |
| 33 | } | ||
| 34 | 543 | auto const it0 = it; | |
| 35 | 543 | std::size_t dn = 0; | |
| 36 | 543 | std::size_t nparam = 1; | |
| 37 |
2/2✓ Branch 0 taken 6750 times.
✓ Branch 1 taken 364 times.
|
7114 | while(it != end) |
| 38 | { | ||
| 39 |
2/2✓ Branch 0 taken 463 times.
✓ Branch 1 taken 6287 times.
|
6750 | if(*it == '&') |
| 40 | { | ||
| 41 | 463 | ++nparam; | |
| 42 | 463 | ++it; | |
| 43 | 463 | continue; | |
| 44 | } | ||
| 45 |
2/2✓ Branch 1 taken 5973 times.
✓ Branch 2 taken 314 times.
|
6287 | if(detail::query_chars(*it)) |
| 46 | { | ||
| 47 | 5973 | ++it; | |
| 48 | 5973 | continue; | |
| 49 | } | ||
| 50 |
2/2✓ Branch 0 taken 147 times.
✓ Branch 1 taken 167 times.
|
314 | if(*it == '%') |
| 51 | { | ||
| 52 |
4/4✓ Branch 0 taken 138 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 135 times.
|
285 | if(end - it < 3 || |
| 53 |
2/2✓ Branch 1 taken 137 times.
✓ Branch 2 taken 1 times.
|
138 | (!grammar::hexdig_chars(it[1]) || |
| 54 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 135 times.
|
137 | !grammar::hexdig_chars(it[2]))) |
| 55 | { | ||
| 56 | // missing valid HEXDIG | ||
| 57 | 12 | break; | |
| 58 | } | ||
| 59 | 135 | it += 3; | |
| 60 | 135 | dn += 2; | |
| 61 | 135 | continue; | |
| 62 | } | ||
| 63 | // got reserved character | ||
| 64 | 167 | break; | |
| 65 | } | ||
| 66 | 543 | std::size_t const n(it - it0); | |
| 67 | 543 | core::string_view str(it0, n); | |
| 68 | 543 | return params_encoded_view( | |
| 69 | 1086 | detail::query_ref( | |
| 70 | 543 | str, n - dn, nparam)); | |
| 71 | } | ||
| 72 | |||
| 73 | } // urls | ||
| 74 | } // boost | ||
| 75 | |||
| 76 |