LibWeb: Set the encoding of HTML documents

Now that we attach the document to the frame before parsing, we have
to make sure we set the encoding on the document before parsing, or
things may not turn out well.
This commit is contained in:
Andreas Kling 2020-12-13 18:21:52 +01:00
parent 024059b49b
commit 7b735b55e1
Notes: sideshowbarker 2024-07-19 00:53:24 +09:00
2 changed files with 3 additions and 2 deletions

View file

@ -113,7 +113,7 @@ static Vector<FlyString> s_quirks_public_ids = {
RefPtr<DOM::Document> parse_html_document(const StringView& data, const URL& url, const String& encoding)
{
auto document = DOM::Document::create(url);
HTMLDocumentParser parser(document, data, TextCodec::get_standardized_encoding(encoding));
HTMLDocumentParser parser(document, data, encoding);
parser.run(url);
return document;
}
@ -122,7 +122,7 @@ HTMLDocumentParser::HTMLDocumentParser(DOM::Document& document, const StringView
: m_tokenizer(input, encoding)
, m_document(document)
{
m_document->set_encoding(encoding);
m_document->set_encoding(TextCodec::get_standardized_encoding(encoding));
}
HTMLDocumentParser::~HTMLDocumentParser()

View file

@ -260,6 +260,7 @@ void FrameLoader::resource_did_load()
auto document = DOM::Document::create();
document->set_url(url);
document->set_encoding(resource()->encoding());
document->set_content_type(resource()->mime_type());
frame().set_document(document);