Browse code

pdf: handle dictionary object with newlines.

Clement Lecigne authored on 2019/03/20 21:29:32
Showing 1 changed files
... ...
@@ -2426,8 +2426,8 @@ static const char *pdf_getdict(const char *q0, int *len, const char *key)
2426 2426
     }
2427 2427
 
2428 2428
     /* if the value is a dictionary object, include the < > brackets.*/
2429
-    if (q[-1] == '<')
2430
-        q--;
2429
+    while (q > q0 && (q[-1] == '<' || q[-1] == '\n'))
2430
+      q--;
2431 2431
 
2432 2432
     *len -= q - q0;
2433 2433
     return q;
... ...
@@ -2559,6 +2559,11 @@ static char *pdf_readstring(const char *q0, int len, const char *key, unsigned *
2559 2559
     if ((*q == '<') && (len >= 3)) {
2560 2560
         start = ++q;
2561 2561
         len -= 1;
2562
+        // skip newlines after <
2563
+        while (len > 0 && *start == '\n') {
2564
+          start = ++q;
2565
+          len -= 1;
2566
+        }
2562 2567
         q = memchr(q + 1, '>', len - 1);
2563 2568
         if (!q)
2564 2569
             return NULL;