From 6133acb8c046c6d3efd0f06563c6bd8452c5771e Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 6 Mar 2022 14:30:38 -0700 Subject: [PATCH] LibPDF: Allow newlines between xref table and "trailer" keyword --- Userland/Libraries/LibPDF/Parser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 6be4afa916..38df8fb0db 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -303,7 +303,7 @@ PDFErrorOr> Parser::parse_xref_table() auto table = adopt_ref(*new XRefTable()); - while (true) { + do { if (m_reader.matches("trailer")) return table; @@ -349,11 +349,16 @@ PDFErrorOr> Parser::parse_xref_table() } table->add_section({ starting_index, object_count, entries }); - } + } while (matches_number()); + + return table; } PDFErrorOr> Parser::parse_file_trailer() { + while (matches_eol()) + consume_eol(); + if (!m_reader.matches("trailer")) return error("Expected \"trailer\" keyword"); m_reader.move_by(7);