Преглед на файлове

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.
MacDue преди 1 година
родител
ревизия
d2f971a919
променени са 1 файла, в които са добавени 11 реда и са изтрити 15 реда
  1. 11 15
      Userland/Libraries/LibXML/Parser/Parser.cpp

+ 11 - 15
Userland/Libraries/LibXML/Parser/Parser.cpp

@@ -568,26 +568,22 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
     TRY(skip_whitespace(Required::Yes));
     doctype.type = TRY(parse_name());
     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()) {
             doctype.external_id = id_result.release_value();
             if (m_options.resolve_external_resource) {
                 auto resource_result = m_options.resolve_external_resource(doctype.external_id->system_id, doctype.external_id->public_id);
-                if (resource_result.is_error()) {
-                    return parse_error(
-                        id_start,
-                        ByteString::formatted("Failed to resolve external subset '{}': {}", doctype.external_id->system_id.system_literal, resource_result.error()));
+                if (!resource_result.is_error()) {
+                    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));
                 }
-                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));
             }
         }
     }