From 56a5f163df4c977700a7c1e7bfed419a2869d37c Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Sun, 31 Jul 2016 00:53:24 -0500 Subject: [PATCH] Fix UTF16 decoding of document outline title Use TextStringToUCS4 function and don't ignore astral characters. Bug #97156 --- poppler/Outline.cc | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) 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; } -- 2.8.1