Browse Source

LibPDF: Require whitespace in front of inline image marker EI

Fixes a crash on page 3 of 0000450.pdf of 0000.zip, where we previously
started interpreting the middle of an inline image content stream as
operators, since it contained `EI` in its pixel data.
Nico Weber 1 năm trước cách đây
mục cha
commit
071f890847
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      Userland/Libraries/LibPDF/Parser.cpp

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

@@ -559,12 +559,13 @@ PDFErrorOr<Vector<Operator>> Parser::parse_operators()
                 // FIXME: Check for ASCIIHexDecode and ASCII85Decode.
                 m_reader.consume(1);
 
-                // FIXME: `EI` can be part of the image data, e.g. on page 3 of 0000450.pdf of 0000.zip of the RGBA dataset.
                 while (!m_reader.done()) {
-                    if (m_reader.matches("EI")) {
+                    // FIXME: Should we allow EI after matches_delimiter() too?
+                    bool expecting_ei = m_reader.matches_whitespace();
+                    m_reader.consume();
+                    if (expecting_ei && m_reader.matches("EI")) {
                         break;
                     }
-                    m_reader.consume();
                 }
 
                 if (m_reader.done())