Skip to content

Commit db41ea8

Browse files
tete17Lubrsi
authored andcommitted
LibWeb: Amend Element interface to make it compatible with TrustedTypes
1 parent 1368744 commit db41ea8

File tree

12 files changed

+94
-62
lines changed

12 files changed

+94
-62
lines changed

Libraries/LibWeb/DOM/Element.cpp

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include <LibWeb/Painting/ViewportPaintable.h>
9090
#include <LibWeb/SVG/SVGAElement.h>
9191
#include <LibWeb/Selection/Selection.h>
92+
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
9293
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
9394
#include <LibWeb/WebIDL/AbstractOperations.h>
9495
#include <LibWeb/WebIDL/DOMException.h>
@@ -370,7 +371,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute_ns(Optional<FlyString> const& n
370371
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_, qualified_name, ValidationContext::Element));
371372

372373
// 2. Let verifiedValue be the result of calling get Trusted Types-compliant attribute value
373-
// with localName, namespace, element, and value.
374+
// with localName, namespace, this, and value.
374375
auto const verified_value = TRY(TrustedTypes::get_trusted_types_compliant_attribute_value(
375376
extracted_qualified_name.local_name(),
376377
extracted_qualified_name.namespace_().has_value() ? Utf16String::from_utf8(extracted_qualified_name.namespace_().value()) : Optional<Utf16String>(),
@@ -1057,15 +1058,22 @@ WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors)
10571058
}
10581059

10591060
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-innerhtml
1060-
WebIDL::ExceptionOr<void> Element::set_inner_html(StringView value)
1061+
WebIDL::ExceptionOr<void> Element::set_inner_html(TrustedTypes::TrustedHTMLOrString const& value)
10611062
{
1062-
// FIXME: 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "Element innerHTML", and "script".
1063+
// 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with
1064+
// TrustedHTML, this's relevant global object, the given value, "Element innerHTML", and "script".
1065+
auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string(
1066+
TrustedTypes::TrustedTypeName::TrustedHTML,
1067+
HTML::relevant_global_object(*this),
1068+
value,
1069+
TrustedTypes::InjectionSink::ElementinnerHTML,
1070+
TrustedTypes::Script.to_string()));
10631071

10641072
// 2. Let context be this.
10651073
DOM::Node* context = this;
10661074

1067-
// 3. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString. FIXME: Use compliantString.
1068-
auto fragment = TRY(as<Element>(*context).parse_fragment(value));
1075+
// 3. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString.
1076+
auto fragment = TRY(as<Element>(*context).parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16()));
10691077

10701078
// 4. If context is a template element, then set context to the template element's template contents (a DocumentFragment).
10711079
auto* template_element = as_if<HTML::HTMLTemplateElement>(*context);
@@ -1089,9 +1097,9 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView value)
10891097
}
10901098

10911099
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-innerhtml
1092-
WebIDL::ExceptionOr<String> Element::inner_html() const
1100+
WebIDL::ExceptionOr<TrustedTypes::TrustedHTMLOrString> Element::inner_html() const
10931101
{
1094-
return serialize_fragment(HTML::RequireWellFormed::Yes);
1102+
return TRY(serialize_fragment(HTML::RequireWellFormed::Yes));
10951103
}
10961104

10971105
bool Element::is_focused() const
@@ -2098,15 +2106,22 @@ WebIDL::ExceptionOr<GC::Ref<DOM::DocumentFragment>> Element::parse_fragment(Stri
20982106
}
20992107

21002108
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-outerhtml
2101-
WebIDL::ExceptionOr<String> Element::outer_html() const
2109+
WebIDL::ExceptionOr<TrustedTypes::TrustedHTMLOrString> Element::outer_html() const
21022110
{
2103-
return serialize_fragment(HTML::RequireWellFormed::Yes, FragmentSerializationMode::Outer);
2111+
return TRY(serialize_fragment(HTML::RequireWellFormed::Yes, FragmentSerializationMode::Outer));
21042112
}
21052113

21062114
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-outerhtml
2107-
WebIDL::ExceptionOr<void> Element::set_outer_html(String const& value)
2115+
WebIDL::ExceptionOr<void> Element::set_outer_html(TrustedTypes::TrustedHTMLOrString const& value)
21082116
{
2109-
// 1. FIXME: Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "Element outerHTML", and "script".
2117+
// 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with
2118+
// TrustedHTML, this's relevant global object, the given value, "Element outerHTML", and "script".
2119+
auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string(
2120+
TrustedTypes::TrustedTypeName::TrustedHTML,
2121+
HTML::relevant_global_object(*this),
2122+
value,
2123+
TrustedTypes::InjectionSink::ElementouterHTML,
2124+
TrustedTypes::Script.to_string()));
21102125

21112126
// 2. Let parent be this's parent.
21122127
auto* parent = this->parent();
@@ -2123,8 +2138,8 @@ WebIDL::ExceptionOr<void> Element::set_outer_html(String const& value)
21232138
if (parent->is_document_fragment())
21242139
parent = TRY(create_element(document(), HTML::TagNames::body, Namespace::HTML));
21252140

2126-
// 6. Let fragment be the result of invoking the fragment parsing algorithm steps given parent and compliantString. FIXME: Use compliantString.
2127-
auto fragment = TRY(as<Element>(*parent).parse_fragment(value));
2141+
// 6. Let fragment be the result of invoking the fragment parsing algorithm steps given parent and compliantString.
2142+
auto fragment = TRY(as<Element>(*parent).parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16()));
21282143

21292144
// 6. Replace this with fragment within this's parent.
21302145
TRY(parent->replace_child(fragment, *this));
@@ -2133,12 +2148,21 @@ WebIDL::ExceptionOr<void> Element::set_outer_html(String const& value)
21332148
}
21342149

21352150
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#the-insertadjacenthtml()-method
2136-
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position, String const& string)
2137-
{
2138-
// 1. Let context be null.
2151+
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position, TrustedTypes::TrustedHTMLOrString const& string)
2152+
{
2153+
// 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with
2154+
// TrustedHTML, this's relevant global object, string, "Element insertAdjacentHTML", and "script".
2155+
auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string(
2156+
TrustedTypes::TrustedTypeName::TrustedHTML,
2157+
HTML::relevant_global_object(*this),
2158+
string,
2159+
TrustedTypes::InjectionSink::ElementinsertAdjacentHTML,
2160+
TrustedTypes::Script.to_string()));
2161+
2162+
// 2. Let context be null.
21392163
GC::Ptr<Node> context;
21402164

2141-
// 2. Use the first matching item from this list:
2165+
// 3. Use the first matching item from this list:
21422166
// - If position is an ASCII case-insensitive match for the string "beforebegin"
21432167
// - If position is an ASCII case-insensitive match for the string "afterend"
21442168
if (position.equals_ignoring_ascii_case("beforebegin"sv)
@@ -2163,7 +2187,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
21632187
return WebIDL::SyntaxError::create(realm(), "insertAdjacentHTML: invalid position argument"_utf16);
21642188
}
21652189

2166-
// 3. If context is not an Element or the following are all true:
2190+
// 4. If context is not an Element or the following are all true:
21672191
// - context's node document is an HTML document,
21682192
// - context's local name is "html", and
21692193
// - context's namespace is the HTML namespace;
@@ -2175,10 +2199,10 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
21752199
context = TRY(create_element(document(), HTML::TagNames::body, Namespace::HTML));
21762200
}
21772201

2178-
// 4. Let fragment be the result of invoking the fragment parsing algorithm steps with context and string.
2179-
auto fragment = TRY(as<Element>(*context).parse_fragment(string));
2202+
// 5. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString.
2203+
auto fragment = TRY(as<Element>(*context).parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16()));
21802204

2181-
// 5. Use the first matching item from this list:
2205+
// 6. Use the first matching item from this list:
21822206

21832207
// - If position is an ASCII case-insensitive match for the string "beforebegin"
21842208
if (position.equals_ignoring_ascii_case("beforebegin"sv)) {
@@ -3936,17 +3960,24 @@ WebIDL::ExceptionOr<String> Element::get_html(GetHTMLOptions const& options) con
39363960
}
39373961

39383962
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-sethtmlunsafe
3939-
WebIDL::ExceptionOr<void> Element::set_html_unsafe(StringView html)
3963+
WebIDL::ExceptionOr<void> Element::set_html_unsafe(TrustedTypes::TrustedHTMLOrString const& html)
39403964
{
3941-
// FIXME: 1. Let compliantHTML be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, html, "Element setHTMLUnsafe", and "script".
3965+
// 1. Let compliantHTML be the result of invoking the Get Trusted Type compliant string algorithm with
3966+
// TrustedHTML, this's relevant global object, html, "Element setHTMLUnsafe", and "script".
3967+
auto const compliant_html = TRY(TrustedTypes::get_trusted_type_compliant_string(
3968+
TrustedTypes::TrustedTypeName::TrustedHTML,
3969+
HTML::relevant_global_object(*this),
3970+
html,
3971+
TrustedTypes::InjectionSink::ElementsetHTMLUnsafe,
3972+
TrustedTypes::Script.to_string()));
39423973

39433974
// 2. Let target be this's template contents if this is a template element; otherwise this.
39443975
DOM::Node* target = this;
39453976
if (is<HTML::HTMLTemplateElement>(*this))
39463977
target = as<HTML::HTMLTemplateElement>(*this).content().ptr();
39473978

3948-
// 3. Unsafe set HTML given target, this, and compliantHTML. FIXME: Use compliantHTML.
3949-
TRY(target->unsafely_set_html(*this, html));
3979+
// 3. Unsafe set HTML given target, this, and compliantHTML.
3980+
TRY(target->unsafely_set_html(*this, compliant_html.to_utf8_but_should_be_ported_to_utf16()));
39503981

39513982
return {};
39523983
}

Libraries/LibWeb/DOM/Element.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,17 @@ class WEB_API Element
239239

240240
[[nodiscard]] GC::Ptr<Element const> element_to_inherit_style_from(Optional<CSS::PseudoElement>) const;
241241

242-
WebIDL::ExceptionOr<String> inner_html() const;
243-
WebIDL::ExceptionOr<void> set_inner_html(StringView);
242+
WebIDL::ExceptionOr<TrustedTypes::TrustedHTMLOrString> inner_html() const;
243+
WebIDL::ExceptionOr<void> set_inner_html(TrustedTypes::TrustedHTMLOrString const&);
244244

245-
WebIDL::ExceptionOr<void> set_html_unsafe(StringView);
245+
WebIDL::ExceptionOr<void> set_html_unsafe(TrustedTypes::TrustedHTMLOrString const&);
246246

247247
WebIDL::ExceptionOr<String> get_html(GetHTMLOptions const&) const;
248248

249-
WebIDL::ExceptionOr<void> insert_adjacent_html(String const& position, String const&);
249+
WebIDL::ExceptionOr<void> insert_adjacent_html(String const& position, TrustedTypes::TrustedHTMLOrString const&);
250250

251-
WebIDL::ExceptionOr<String> outer_html() const;
252-
WebIDL::ExceptionOr<void> set_outer_html(String const&);
251+
WebIDL::ExceptionOr<TrustedTypes::TrustedHTMLOrString> outer_html() const;
252+
WebIDL::ExceptionOr<void> set_outer_html(TrustedTypes::TrustedHTMLOrString const&);
253253

254254
bool is_focused() const;
255255
bool is_active() const;

Libraries/LibWeb/DOM/Element.idl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#import <Geometry/DOMRectList.idl>
1515
#import <HTML/HTMLSlotElement.idl>
1616
#import <HTML/Window.idl>
17+
#import <TrustedTypes/TrustedHTML.idl>
1718
#import <TrustedTypes/TrustedTypePolicy.idl>
1819

1920
enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
@@ -109,18 +110,14 @@ interface Element : Node {
109110
readonly attribute double currentCSSZoom;
110111

111112
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
112-
// FIXME: [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html);
113-
[CEReactions] undefined setHTMLUnsafe(DOMString html);
113+
[CEReactions] undefined setHTMLUnsafe((TrustedHTML or Utf16DOMString) html);
114114
DOMString getHTML(optional GetHTMLOptions options = {});
115115

116-
// FIXME: [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;
117-
[CEReactions, LegacyNullToEmptyString] attribute DOMString innerHTML;
116+
[CEReactions, LegacyNullToEmptyString] attribute (TrustedHTML or Utf16DOMString) innerHTML;
118117

119-
// FIXME: [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) outerHTML;
120-
[CEReactions, LegacyNullToEmptyString] attribute DOMString outerHTML;
118+
[CEReactions, LegacyNullToEmptyString] attribute (TrustedHTML or Utf16DOMString) outerHTML;
121119

122-
// FIXME: [CEReactions] undefined insertAdjacentHTML(DOMString position, (TrustedHTML or DOMString) string);
123-
[CEReactions] undefined insertAdjacentHTML(DOMString position, DOMString text);
120+
[CEReactions] undefined insertAdjacentHTML(DOMString position, (TrustedHTML or Utf16DOMString) text);
124121

125122
// https://w3c.github.io/pointerevents/#extensions-to-the-element-interface
126123
undefined setPointerCapture(long pointerId);

Libraries/LibWeb/DOM/Node.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,14 +2091,14 @@ void Node::string_replace_all(Utf16String string)
20912091
}
20922092

20932093
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#fragment-serializing-algorithm-steps
2094-
WebIDL::ExceptionOr<String> Node::serialize_fragment(HTML::RequireWellFormed require_well_formed, FragmentSerializationMode fragment_serialization_mode) const
2094+
WebIDL::ExceptionOr<Utf16String> Node::serialize_fragment(HTML::RequireWellFormed require_well_formed, FragmentSerializationMode fragment_serialization_mode) const
20952095
{
20962096
// 1. Let context document be the value of node's node document.
20972097
auto const& context_document = document();
20982098

20992099
// 2. If context document is an HTML document, return the result of HTML fragment serialization algorithm with node, false, and « ».
21002100
if (context_document.is_html_document())
2101-
return HTML::HTMLParser::serialize_html_fragment(*this, HTML::HTMLParser::SerializableShadowRoots::No, {}, fragment_serialization_mode);
2101+
return Utf16String::from_utf8(HTML::HTMLParser::serialize_html_fragment(*this, HTML::HTMLParser::SerializableShadowRoots::No, {}, fragment_serialization_mode));
21022102

21032103
// 3. Return the XML serialization of node given require well-formed.
21042104
// AD-HOC: XML serialization algorithm returns the "outer" XML serialization of the node.
@@ -2109,9 +2109,9 @@ WebIDL::ExceptionOr<String> Node::serialize_fragment(HTML::RequireWellFormed req
21092109
auto child_markup = TRY(HTML::serialize_node_to_xml_string(*child, require_well_formed));
21102110
markup.append(child_markup.bytes_as_string_view());
21112111
}
2112-
return MUST(markup.to_string());
2112+
return Utf16String::from_utf8(MUST(markup.to_string()));
21132113
}
2114-
return HTML::serialize_node_to_xml_string(*this, require_well_formed);
2114+
return Utf16String::from_utf8(TRY(HTML::serialize_node_to_xml_string(*this, require_well_formed)));
21152115
}
21162116

21172117
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#unsafely-set-html

Libraries/LibWeb/DOM/Node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class WEB_API Node : public EventTarget
403403
[[nodiscard]] UniqueNodeID unique_id() const { return m_unique_id; }
404404
static Node* from_unique_id(UniqueNodeID);
405405

406-
WebIDL::ExceptionOr<String> serialize_fragment(HTML::RequireWellFormed, FragmentSerializationMode = FragmentSerializationMode::Inner) const;
406+
WebIDL::ExceptionOr<Utf16String> serialize_fragment(HTML::RequireWellFormed, FragmentSerializationMode = FragmentSerializationMode::Inner) const;
407407

408408
WebIDL::ExceptionOr<void> unsafely_set_html(Element&, StringView);
409409

Libraries/LibWeb/DOM/ShadowRoot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ EventTarget* ShadowRoot::get_parent(Event const& event)
6565
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml
6666
WebIDL::ExceptionOr<String> ShadowRoot::inner_html() const
6767
{
68-
return serialize_fragment(HTML::RequireWellFormed::Yes);
68+
return TRY(serialize_fragment(HTML::RequireWellFormed::Yes)).to_utf8_but_should_be_ported_to_utf16();
6969
}
7070

7171
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml

Libraries/LibWeb/HTML/HTMLInputElement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
11031103
padding: 0;
11041104
cursor: default;
11051105
)~~~"_string));
1106-
MUST(up_button->set_inner_html("<svg style=\"width: 1em; height: 1em;\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z\" /></svg>"sv));
1106+
MUST(up_button->set_inner_html("<svg style=\"width: 1em; height: 1em;\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z\" /></svg>"_utf16));
11071107
MUST(element->append_child(up_button));
11081108

11091109
auto mouseup_callback_function = JS::NativeFunction::create(
@@ -1135,7 +1135,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
11351135
padding: 0;
11361136
cursor: default;
11371137
)~~~"_string));
1138-
MUST(down_button->set_inner_html("<svg style=\"width: 1em; height: 1em;\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z\" /></svg>"sv));
1138+
MUST(down_button->set_inner_html("<svg style=\"width: 1em; height: 1em;\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z\" /></svg>"_utf16));
11391139
MUST(element->append_child(down_button));
11401140

11411141
auto down_callback_function = JS::NativeFunction::create(

Libraries/LibWeb/HTML/HTMLSelectElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ void HTMLSelectElement::create_shadow_tree_if_needed()
612612
height: 16px;
613613
margin-left: 4px;
614614
)~~~"_string));
615-
MUST(m_chevron_icon_element->set_inner_html(chevron_svg));
615+
MUST(m_chevron_icon_element->set_inner_html(Utf16String::from_utf8(chevron_svg)));
616616
MUST(border->append_child(*m_chevron_icon_element));
617617

618618
update_inner_text_element();

Libraries/LibWeb/TrustedTypes/InjectionSink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ namespace Web::TrustedTypes {
2121
__ENUMERATE_INJECTION_SINKS(Documentwrite, "Document write") \
2222
__ENUMERATE_INJECTION_SINKS(Documentwriteln, "Document writeln") \
2323
__ENUMERATE_INJECTION_SINKS(DocumentexecCommand, "Document execCommand") \
24+
__ENUMERATE_INJECTION_SINKS(ElementinnerHTML, "Element innerHTML") \
25+
__ENUMERATE_INJECTION_SINKS(ElementinsertAdjacentHTML, "Element insertAdjacentHTML") \
26+
__ENUMERATE_INJECTION_SINKS(ElementouterHTML, "Element outerHTML") \
27+
__ENUMERATE_INJECTION_SINKS(ElementsetHTMLUnsafe, "Element setHTMLUnsafe") \
2428
__ENUMERATE_INJECTION_SINKS(Function, "Function") \
2529
__ENUMERATE_INJECTION_SINKS(HTMLIFrameElementsrcdoc, "HTMLIFrameElement srcdoc") \
2630
__ENUMERATE_INJECTION_SINKS(HTMLScriptElementinnerText, "HTMLScriptElement innerText") \

Libraries/LibWeb/XHR/XMLHttpRequest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
573573
// 2. If body is a Document, then set this’s request body to body, serialized, converted, and UTF-8 encoded.
574574
if (body->has<GC::Root<DOM::Document>>()) {
575575
auto string_serialized_document = TRY(body->get<GC::Root<DOM::Document>>().cell()->serialize_fragment(HTML::RequireWellFormed::No));
576-
m_request_body = Fetch::Infrastructure::byte_sequence_as_body(realm, string_serialized_document.bytes());
576+
m_request_body = Fetch::Infrastructure::byte_sequence_as_body(realm, string_serialized_document.to_utf8().bytes());
577577
}
578578
// 3. Otherwise:
579579
else {

0 commit comments

Comments
 (0)