From 621b50e57a3b22ae386a4b715faa7102683d0439 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Wed, 7 Feb 2024 11:27:27 -0300 Subject: [PATCH] refactor: no implicit char conversions fix #816 --- include/boost/url/detail/encode.hpp | 3 ++- include/boost/url/grammar/lut_chars.hpp | 8 ++++++++ test/unit/test_rule.hpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/boost/url/detail/encode.hpp b/include/boost/url/detail/encode.hpp index a0fc5d00c..90445b749 100644 --- a/include/boost/url/detail/encode.hpp +++ b/include/boost/url/detail/encode.hpp @@ -115,8 +115,9 @@ re_encode_unsafe( detail::hexdigs[opt.lower_case]; auto const encode = [end, hex]( char*& dest, - unsigned char c) noexcept + char c0) noexcept { + auto c = static_cast(c0); ignore_unused(end); *dest++ = '%'; BOOST_ASSERT(dest != end); diff --git a/include/boost/url/grammar/lut_chars.hpp b/include/boost/url/grammar/lut_chars.hpp index 0454a8a99..d160880e6 100644 --- a/include/boost/url/grammar/lut_chars.hpp +++ b/include/boost/url/grammar/lut_chars.hpp @@ -257,6 +257,14 @@ class lut_chars bool operator()( unsigned char ch) const noexcept + { + return operator()(static_cast(ch)); + } + + /// @copydoc operator()(unsigned char) const + constexpr + bool + operator()(char ch) const noexcept { return mask_[lo(ch)] & hi(ch); } diff --git a/test/unit/test_rule.hpp b/test/unit/test_rule.hpp index 5fcf76eaf..e15ff29f4 100644 --- a/test/unit/test_rule.hpp +++ b/test/unit/test_rule.hpp @@ -60,7 +60,7 @@ test_char_set( for_each_char( [&cs](char c) { - if(cs(0) || ! cs(c)) + if(cs(static_cast(0)) || ! cs(c)) { if(cs(c)) {