From d2b89afed20d03f02d9f47d1f98d2f7f5f34e58a Mon Sep 17 00:00:00 2001 From: Tianyuan Fu Date: Mon, 27 Feb 2023 17:34:28 +0800 Subject: [PATCH] Make header prefix matching case-insensitive in authProxy --- plugins/authproxy/tests/authproxy_test.cc | 4 +++- plugins/authproxy/utils.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/authproxy/tests/authproxy_test.cc b/plugins/authproxy/tests/authproxy_test.cc index c9026cb3202..ad527e9021f 100644 --- a/plugins/authproxy/tests/authproxy_test.cc +++ b/plugins/authproxy/tests/authproxy_test.cc @@ -34,6 +34,8 @@ TEST_CASE("Util methods", "[authproxy][utility]") CHECK(ContainsPrefix(string_view{"abc"}, "") == true); CHECK(ContainsPrefix(string_view{""}, "abc") == false); CHECK(ContainsPrefix(string_view{"abcdef"}, "abc\0") == true); - CHECK(ContainsPrefix(string_view{"abcdef\0"}, "abc\0") == true); + CHECK(ContainsPrefix(string_view{"AbCdef\0"}, "abc\0") == true); + CHECK(ContainsPrefix(string_view{"abcdef\0"}, "aBc\0") == true); + CHECK(ContainsPrefix(string_view{"abc\0"}, "aBcdEf\0") == false); } } diff --git a/plugins/authproxy/utils.h b/plugins/authproxy/utils.h index a7224a1802a..1249a3eb911 100644 --- a/plugins/authproxy/utils.h +++ b/plugins/authproxy/utils.h @@ -113,6 +113,6 @@ void HttpDebugHeader(TSMBuffer mbuf, TSMLoc mhdr); inline bool ContainsPrefix(const std::string_view str, const std::string &prefix) { - return str.size() < prefix.size() ? false : (strncmp(str.data(), prefix.data(), prefix.size()) == 0); + return str.size() < prefix.size() ? false : (strncasecmp(str.data(), prefix.data(), prefix.size()) == 0); } // vim: set ts=4 sw=4 et :