[poppler] poppler/Outline.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Sep 4 09:12:54 UTC 2016


 poppler/Outline.cc |   18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

New commits:
commit 92175cb29450241fafc6d74170f97aee5b7a6d7a
Author: Jason Crain <jason at inspiresomeone.us>
Date:   Sun Jul 31 00:53:24 2016 -0500

    Fix UTF16 decoding of document outline title
    
    Use TextStringToUCS4 function and don't ignore astral characters.
    
    Bug #97156

diff --git a/poppler/Outline.cc b/poppler/Outline.cc
index bd4e6d0..cc1bc1a 100644
--- a/poppler/Outline.cc
+++ b/poppler/Outline.cc
@@ -35,6 +35,7 @@
 #include "Link.h"
 #include "PDFDocEncoding.h"
 #include "Outline.h"
+#include "UTF.h"
 
 //------------------------------------------------------------------------
 
@@ -63,7 +64,6 @@ Outline::~Outline() {
 OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
   Object obj1;
   GooString *s;
-  int i;
 
   xref = xrefA;
   title = NULL;
@@ -72,21 +72,7 @@ OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
 
   if (dict->lookup("Title", &obj1)->isString()) {
     s = obj1.getString();
-    if ((s->getChar(0) & 0xff) == 0xfe &&
-	(s->getChar(1) & 0xff) == 0xff) {
-      titleLen = (s->getLength() - 2) / 2;
-      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
-      for (i = 0; i < titleLen; ++i) {
-	title[i] = ((s->getChar(2 + 2*i) & 0xff) << 8) |
-	           (s->getChar(3 + 2*i) & 0xff);
-      }
-    } else {
-      titleLen = s->getLength();
-      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
-      for (i = 0; i < titleLen; ++i) {
-	title[i] = pdfDocEncoding[s->getChar(i) & 0xff];
-      }
-    }
+    titleLen = TextStringToUCS4(s, &title);
   } else {
     titleLen = 0;
   }


More information about the poppler mailing list