1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

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.
This commit is contained in:
Nico Weber 2023-11-14 10:48:39 -05:00 committed by Sam Atkins
parent 5513f8bbe3
commit 54c98a46d8

View file

@ -520,17 +520,20 @@ PDFErrorOr<Vector<Operator>> Parser::parse_operators()
Vector<Operator> operators;
Vector<Value> 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;