From bad6ad8861bf3b24b89400a0de464436e0330add Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 19 Jul 2022 00:18:45 +0100 Subject: [PATCH] LibWeb: Implement CaseInsensitiveBytesTraits::equals() Turns out HashTable::contains() doesn't solely use hash() for equality checks, so the lack of a proper equals() implementation broke the check in convert_header_names_to_a_sorted_lowercase_set() and caused duplicate entries in header_names_set. --- .../Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp index d2b3fb4549..96daf55e00 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp @@ -20,7 +20,12 @@ namespace Web::Fetch::Infrastructure { template requires(IsSameIgnoringCV) struct CaseInsensitiveBytesTraits : public Traits> { - static unsigned hash(Span const& span) + static constexpr bool equals(Span const& a, Span const& b) + { + return StringView { a }.equals_ignoring_case(StringView { b }); + } + + static constexpr unsigned hash(Span const& span) { if (span.is_empty()) return 0;