LibWeb: Ensure Headers API can handle non-ascii characters

This patch ensure Headers object's associated header list
is ISO-8859-1 encoded when set using `Infra::isomorphic_encode`,
and correctly decoded using `Infra::isomorphic_decode`.

Follow-up of https://github.com/LadybirdBrowser/ladybird/pull/1893
This commit is contained in:
Feng Yu 2024-12-06 09:35:02 -08:00 committed by Andrew Kaster
parent 5e62f548db
commit 824e91ffdb
Notes: github-actions[bot] 2024-12-11 23:50:13 +00:00
7 changed files with 188 additions and 13 deletions

View file

@ -9,6 +9,7 @@
#include <LibWeb/Bindings/HeadersIteratorPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Fetch/HeadersIterator.h>
#include <LibWeb/Infra/Strings.h>
namespace Web::Bindings {
@ -65,8 +66,8 @@ GC::Ref<JS::Object> HeadersIterator::next()
return create_iterator_result_object(vm(), JS::js_undefined(), true);
auto const& pair = pairs[m_index++];
StringView pair_name { pair.name };
StringView pair_value { pair.value };
auto pair_name = Infra::isomorphic_decode(pair.name);
auto pair_value = Infra::isomorphic_decode(pair.value);
switch (m_iteration_kind) {
case JS::Object::PropertyKind::Key: