From 54c98a46d86daa305848a37f6791ce6aa410dc67 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 14 Nov 2023 10:48:39 -0500 Subject: [PATCH] LibPDF: Correctly parse the d0 and d1 operators They are the first operator in a type 3 charproc. Operator.h already knew about them, but we didn't manage to parse them, since they're the only two operators that contain a digit. --- Userland/Libraries/LibPDF/Parser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 00a428e7eb..73a50f82dd 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -520,17 +520,20 @@ PDFErrorOr> Parser::parse_operators() Vector operators; Vector operator_args; - constexpr static auto is_operator_char = [](char ch) { + constexpr static auto is_operator_char_start = [](char ch) { return isalpha(ch) || ch == '*' || ch == '\'' || ch == '"'; }; + constexpr static auto is_operator_char_continuation = [](char ch) { + return is_operator_char_start(ch) || ch == '0' || ch == '1'; + }; m_reader.consume_whitespace(); while (!m_reader.done()) { auto ch = m_reader.peek(); - if (is_operator_char(ch)) { + if (is_operator_char_start(ch)) { auto operator_start = m_reader.offset(); - while (is_operator_char(ch)) { + while (is_operator_char_continuation(ch)) { m_reader.consume(); if (m_reader.done()) break;