Browse Source

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.
Nico Weber 1 year ago
parent
commit
54c98a46d8
1 changed files with 6 additions and 3 deletions
  1. 6 3
      Userland/Libraries/LibPDF/Parser.cpp

+ 6 - 3
Userland/Libraries/LibPDF/Parser.cpp

@@ -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;