summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibPDF
diff options
context:
space:
mode:
authorJulian Offenhäuser <offenhaeuser@protonmail.com>2023-03-21 20:02:11 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-22 09:04:00 +0100
commitfd7887566297623cde57131257720bb22b8117a7 (patch)
treef114fcae56ccd5a978709152a434f8a1fa9a2bf4 /Userland/Libraries/LibPDF
parentfca9da419108a0b415bfcec9c1bcc960988aceae (diff)
downloadserenity-fd7887566297623cde57131257720bb22b8117a7.zip
LibPDF: Fix navigate_to_before_eof_marker() for PDFs not ending in EOL
The way this was factored before, we would miss the %%EOF marker if it didn't have a valid end-of-line sequence after it.
Diffstat (limited to 'Userland/Libraries/LibPDF')
-rw-r--r--Userland/Libraries/LibPDF/DocumentParser.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/Userland/Libraries/LibPDF/DocumentParser.cpp b/Userland/Libraries/LibPDF/DocumentParser.cpp
index e2c1538e6e..7d7f3d1f9b 100644
--- a/Userland/Libraries/LibPDF/DocumentParser.cpp
+++ b/Userland/Libraries/LibPDF/DocumentParser.cpp
@@ -692,19 +692,13 @@ bool DocumentParser::navigate_to_before_eof_marker()
m_reader.set_reading_backwards();
while (!m_reader.done()) {
- m_reader.move_until([&](auto) { return m_reader.matches_eol(); });
- if (m_reader.done())
- return false;
-
m_reader.consume_eol();
- if (!m_reader.matches("%%EOF"))
- continue;
+ if (m_reader.matches("%%EOF")) {
+ m_reader.move_by(5);
+ return true;
+ }
- m_reader.move_by(5);
- if (!m_reader.matches_eol())
- continue;
- m_reader.consume_eol();
- return true;
+ m_reader.move_until([&](auto) { return m_reader.matches_eol(); });
}
return false;