From: Alex Rousskov Date: Thu, 25 May 2023 02:10:28 +0000 (+0000) Subject: Fix userinfo percent-encoding (#1367) X-Git-Tag: SQUID_6_4~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7de01969a793b2fdb476e354a9fcda272d400d27;p=thirdparty%2Fsquid.git Fix userinfo percent-encoding (#1367) %X expects an unsigned int, and that is what we were giving it. However, to get to the correct unsigned int value from a (signed) char, one has to cast to an unsigned char (or equivalent) first. Broken since inception in commit 7b75100. Also adjusted similar (commented out) ext_edirectory_userip_acl code. --- diff --git a/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc b/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc index bf124d24f9..e3f33e2094 100644 --- a/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc +++ b/src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc @@ -1555,7 +1555,7 @@ MainSafe(int argc, char **argv) /* BINARY DEBUGGING * local_printfx("while() -> bufa[%" PRIuSIZE "]: %s", k, bufa); for (i = 0; i < k; ++i) - local_printfx("%02X", bufa[i]); + local_printfx("%02X", static_cast(static_cast(bufa[i]))); local_printfx("\n"); * BINARY DEBUGGING */ /* Check for CRLF */ diff --git a/src/anyp/Uri.cc b/src/anyp/Uri.cc index e372939968..eca2c23573 100644 --- a/src/anyp/Uri.cc +++ b/src/anyp/Uri.cc @@ -71,7 +71,7 @@ AnyP::Uri::Encode(const SBuf &buf, const CharacterSet &ignore) while (!tk.atEnd()) { // TODO: Add Tokenizer::parseOne(void). const auto ch = tk.remaining()[0]; - output.appendf("%%%02X", static_cast(ch)); // TODO: Optimize using a table + output.appendf("%%%02X", static_cast(static_cast(ch))); // TODO: Optimize using a table (void)tk.skip(ch); if (tk.prefix(goodSection, ignore))