mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 04:39:10 +00:00
LibXML: Don't emit a parser error for failing to resolve DTD URI
This prevented loading SVGs such as: https://mdn.github.io/learning-area/html/multimedia-and-embedding/mdn-splash-page-finished/mdn.svg Where the DTD is not in the hardcoded unified DTD in LibWeb. It also prevented loading any SVG with a broken link for a DTD, which other browsers just seem to ignore.
This commit is contained in:
parent
966b042db6
commit
d2f971a919
Notes:
sideshowbarker
2024-07-17 09:48:50 +09:00
Author: https://github.com/MacDue
Commit: d2f971a919
Pull-request: https://github.com/SerenityOS/serenity/pull/23767
1 changed files with 11 additions and 15 deletions
|
@ -568,26 +568,22 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
|
||||||
TRY(skip_whitespace(Required::Yes));
|
TRY(skip_whitespace(Required::Yes));
|
||||||
doctype.type = TRY(parse_name());
|
doctype.type = TRY(parse_name());
|
||||||
if (auto result = skip_whitespace(Required::Yes); !result.is_error()) {
|
if (auto result = skip_whitespace(Required::Yes); !result.is_error()) {
|
||||||
auto id_start = m_lexer.tell();
|
|
||||||
if (auto id_result = parse_external_id(); !id_result.is_error()) {
|
if (auto id_result = parse_external_id(); !id_result.is_error()) {
|
||||||
doctype.external_id = id_result.release_value();
|
doctype.external_id = id_result.release_value();
|
||||||
if (m_options.resolve_external_resource) {
|
if (m_options.resolve_external_resource) {
|
||||||
auto resource_result = m_options.resolve_external_resource(doctype.external_id->system_id, doctype.external_id->public_id);
|
auto resource_result = m_options.resolve_external_resource(doctype.external_id->system_id, doctype.external_id->public_id);
|
||||||
if (resource_result.is_error()) {
|
if (!resource_result.is_error()) {
|
||||||
return parse_error(
|
StringView resolved_source = resource_result.value();
|
||||||
id_start,
|
TemporaryChange source { m_source, resolved_source };
|
||||||
ByteString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
|
TemporaryChange lexer { m_lexer, LineTrackingLexer(m_source) };
|
||||||
|
auto declarations = TRY(parse_external_subset());
|
||||||
|
if (!m_lexer.is_eof()) {
|
||||||
|
return parse_error(
|
||||||
|
m_lexer.tell(),
|
||||||
|
ByteString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
|
||||||
|
}
|
||||||
|
doctype.markup_declarations.extend(move(declarations));
|
||||||
}
|
}
|
||||||
StringView resolved_source = resource_result.value();
|
|
||||||
TemporaryChange source { m_source, resolved_source };
|
|
||||||
TemporaryChange lexer { m_lexer, LineTrackingLexer(m_source) };
|
|
||||||
auto declarations = TRY(parse_external_subset());
|
|
||||||
if (!m_lexer.is_eof()) {
|
|
||||||
return parse_error(
|
|
||||||
m_lexer.tell(),
|
|
||||||
ByteString::formatted("Failed to resolve external subset '{}': garbage after declarations", doctype.external_id->system_id.system_literal));
|
|
||||||
}
|
|
||||||
doctype.markup_declarations.extend(move(declarations));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue