Ver código fonte

LibPDF: Fix two parser bugs

- A newline was assumed to follow the "stream" keyword, when it can also
  be a windows-style line break
- Fix not consuming the "endobj" at the end of every indirect object
Matthew Olsson 4 anos atrás
pai
commit
be1be47613
1 arquivos alterados com 4 adições e 1 exclusões
  1. 4 1
      Userland/Libraries/LibPDF/Parser.cpp

+ 4 - 1
Userland/Libraries/LibPDF/Parser.cpp

@@ -316,7 +316,7 @@ Value Parser::parse_value()
         auto dict = parse_dict();
         auto dict = parse_dict();
         if (!dict)
         if (!dict)
             return {};
             return {};
-        if (m_reader.matches("stream\n"))
+        if (m_reader.matches("stream"))
             return parse_stream(dict.release_nonnull());
             return parse_stream(dict.release_nonnull());
         return dict;
         return dict;
     }
     }
@@ -371,6 +371,9 @@ RefPtr<IndirectValue> Parser::parse_indirect_value(int index, int generation)
     if (!m_reader.matches("endobj"))
     if (!m_reader.matches("endobj"))
         return {};
         return {};
 
 
+    consume(6);
+    consume_whitespace();
+
     return make_object<IndirectValue>(index, generation, value);
     return make_object<IndirectValue>(index, generation, value);
 }
 }