Bladeren bron

LibPDF: Ignore whitespace on hex strings

The spec says that whitespaces should be ignored, but we weren't. PDFs
with whitespaces in their hex strings were thus crushing the parser.
Rodrigo Tobar 2 jaren geleden
bovenliggende
commit
e776048309
1 gewijzigde bestanden met toevoegingen van 1 en 1 verwijderingen
  1. 1 1
      Userland/Libraries/LibPDF/Parser.cpp

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

@@ -364,6 +364,7 @@ String Parser::parse_hex_string()
             int hex_value = 0;
             int hex_value = 0;
 
 
             for (int i = 0; i < 2; i++) {
             for (int i = 0; i < 2; i++) {
+                m_reader.consume_whitespace();
                 auto ch = m_reader.consume();
                 auto ch = m_reader.consume();
                 if (ch == '>') {
                 if (ch == '>') {
                     // The hex string contains an odd number of characters, and the last character
                     // The hex string contains an odd number of characters, and the last character
@@ -373,7 +374,6 @@ String Parser::parse_hex_string()
                     builder.append(static_cast<char>(hex_value));
                     builder.append(static_cast<char>(hex_value));
                     return builder.to_string();
                     return builder.to_string();
                 }
                 }
-
                 VERIFY(isxdigit(ch));
                 VERIFY(isxdigit(ch));
 
 
                 hex_value *= 16;
                 hex_value *= 16;