90.00% Lines (27/30)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | |||||
| 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_RFC_IMPL_QUERY_RULE_HPP | 11 | #ifndef BOOST_URL_RFC_IMPL_QUERY_RULE_HPP | |||||
| 12 | #define BOOST_URL_RFC_IMPL_QUERY_RULE_HPP | 12 | #define BOOST_URL_RFC_IMPL_QUERY_RULE_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/detail/config.hpp> | 14 | #include <boost/url/detail/config.hpp> | |||||
| 15 | #include <boost/url/rfc/detail/charsets.hpp> | 15 | #include <boost/url/rfc/detail/charsets.hpp> | |||||
| 16 | #include <boost/url/error.hpp> | 16 | #include <boost/url/error.hpp> | |||||
| 17 | #include <boost/url/grammar/hexdig_chars.hpp> | 17 | #include <boost/url/grammar/hexdig_chars.hpp> | |||||
| 18 | 18 | |||||||
| 19 | namespace boost { | 19 | namespace boost { | |||||
| 20 | namespace urls { | 20 | namespace urls { | |||||
| 21 | 21 | |||||||
| 22 | inline | 22 | inline | |||||
| 23 | auto | 23 | auto | |||||
| HITCBC | 24 | 3157 | implementation_defined::query_rule_t:: | 24 | 3157 | implementation_defined::query_rule_t:: | ||
| 25 | parse( | 25 | parse( | |||||
| 26 | char const*& it, | 26 | char const*& it, | |||||
| 27 | char const* end | 27 | char const* end | |||||
| 28 | ) const noexcept -> | 28 | ) const noexcept -> | |||||
| 29 | system::result<value_type> | 29 | system::result<value_type> | |||||
| 30 | { | 30 | { | |||||
| HITCBC | 31 | 3157 | if(it == end) | 31 | 3157 | if(it == end) | ||
| 32 | { | 32 | { | |||||
| 33 | // empty string = 1 param | 33 | // empty string = 1 param | |||||
| MISUBC | 34 | ✗ | core::string_view str(it, 0); | 34 | ✗ | core::string_view str(it, 0); | ||
| MISUBC | 35 | ✗ | return params_encoded_view( | 35 | ✗ | return params_encoded_view( | ||
| MISUBC | 36 | ✗ | detail::query_ref(str, 0, 1)); | 36 | ✗ | detail::query_ref(str, 0, 1)); | ||
| 37 | } | 37 | } | |||||
| HITCBC | 38 | 3157 | auto const it0 = it; | 38 | 3157 | auto const it0 = it; | ||
| HITCBC | 39 | 3157 | std::size_t dn = 0; | 39 | 3157 | std::size_t dn = 0; | ||
| HITCBC | 40 | 3157 | std::size_t nparam = 1; | 40 | 3157 | std::size_t nparam = 1; | ||
| HITCBC | 41 | 24337 | while(it != end) | 41 | 24337 | while(it != end) | ||
| 42 | { | 42 | { | |||||
| HITCBC | 43 | 24175 | if(*it == '&') | 43 | 24175 | if(*it == '&') | ||
| 44 | { | 44 | { | |||||
| HITCBC | 45 | 428 | ++nparam; | 45 | 428 | ++nparam; | ||
| HITCBC | 46 | 428 | ++it; | 46 | 428 | ++it; | ||
| HITCBC | 47 | 428 | continue; | 47 | 428 | continue; | ||
| 48 | } | 48 | } | |||||
| HITCBC | 49 | 23747 | if(detail::query_chars(*it)) | 49 | 23747 | if(detail::query_chars(*it)) | ||
| 50 | { | 50 | { | |||||
| HITCBC | 51 | 20499 | ++it; | 51 | 20499 | ++it; | ||
| HITCBC | 52 | 20499 | continue; | 52 | 20499 | continue; | ||
| 53 | } | 53 | } | |||||
| HITCBC | 54 | 3248 | if(*it == '%') | 54 | 3248 | if(*it == '%') | ||
| 55 | { | 55 | { | |||||
| HITCBC | 56 | 589 | if(end - it < 3 || | 56 | 589 | if(end - it < 3 || | ||
| HITCBC | 57 | 289 | (!grammar::hexdig_chars(it[1]) || | 57 | 289 | (!grammar::hexdig_chars(it[1]) || | ||
| HITCBC | 58 | 271 | !grammar::hexdig_chars(it[2]))) | 58 | 271 | !grammar::hexdig_chars(it[2]))) | ||
| 59 | { | 59 | { | |||||
| 60 | // missing valid HEXDIG | 60 | // missing valid HEXDIG | |||||
| HITCBC | 61 | 47 | break; | 61 | 47 | break; | ||
| 62 | } | 62 | } | |||||
| HITCBC | 63 | 253 | it += 3; | 63 | 253 | it += 3; | ||
| HITCBC | 64 | 253 | dn += 2; | 64 | 253 | dn += 2; | ||
| HITCBC | 65 | 253 | continue; | 65 | 253 | continue; | ||
| 66 | } | 66 | } | |||||
| 67 | // got reserved character | 67 | // got reserved character | |||||
| HITCBC | 68 | 2948 | break; | 68 | 2948 | break; | ||
| 69 | } | 69 | } | |||||
| HITCBC | 70 | 3157 | std::size_t const n(it - it0); | 70 | 3157 | std::size_t const n(it - it0); | ||
| HITCBC | 71 | 3157 | core::string_view str(it0, n); | 71 | 3157 | core::string_view str(it0, n); | ||
| HITCBC | 72 | 3157 | return params_encoded_view( | 72 | 3157 | return params_encoded_view( | ||
| HITCBC | 73 | 6314 | detail::query_ref( | 73 | 6314 | detail::query_ref( | ||
| HITCBC | 74 | 3157 | str, n - dn, nparam)); | 74 | 3157 | str, n - dn, nparam)); | ||
| 75 | } | 75 | } | |||||
| 76 | 76 | |||||||
| 77 | } // urls | 77 | } // urls | |||||
| 78 | } // boost | 78 | } // boost | |||||
| 79 | 79 | |||||||
| 80 | 80 | |||||||
| 81 | #endif | 81 | #endif | |||||