[poppler] qt5/src qt5/tests qt6/src qt6/tests

2021-04-14 Thread GitLab Mirror
 qt5/src/poppler-private.cc  |4 
 qt5/tests/check_strings.cpp |   12 +---
 qt6/src/poppler-private.cc  |4 
 qt6/tests/check_strings.cpp |   12 +---
 4 files changed, 26 insertions(+), 6 deletions(-)

New commits:
commit b770a55a47278f4104fc410034577cc4ea0434a6
Author: Albert Astals Cid 
Date:   Tue Apr 13 17:59:34 2021 +0200

qt: QStringToUnicodeGooString don't produce a "fake empty" string

if the input string is empty, just return an empty GooString, not a
GooString with only the unicode marker

diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 5b30f19c..695b9b8c 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -9,6 +9,7 @@
  * Copyright (C) 2018-2020 Adam Reichold 
  * Copyright (C) 2019, 2020 Oliver Sander 
  * Copyright (C) 2019 João Netto 
+ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, 

  * Inspired on code by
  * Copyright (C) 2004 by Albert Astals Cid 
  * Copyright (C) 2004 by Enrico Ros 
@@ -115,6 +116,9 @@ QString UnicodeParsedString(const std::string )
 
 GooString *QStringToUnicodeGooString(const QString )
 {
+if (s.isEmpty()) {
+return new GooString();
+}
 int len = s.length() * 2 + 2;
 char *cstring = (char *)gmallocn(len, sizeof(char));
 cstring[0] = (char)0xfe;
diff --git a/qt5/tests/check_strings.cpp b/qt5/tests/check_strings.cpp
index 4c996c4f..14d22740 100644
--- a/qt5/tests/check_strings.cpp
+++ b/qt5/tests/check_strings.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010, 2011, Pino Toscano 
+ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, 

  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -189,9 +190,14 @@ void TestStrings::check_QStringToUnicodeGooString()
 QFETCH(QByteArray, result);
 
 GooString *goo = Poppler::QStringToUnicodeGooString(string);
-QVERIFY(goo->hasUnicodeMarker());
-QCOMPARE(goo->getLength(), string.length() * 2 + 2);
-QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, 
goo->getLength() - 2));
+if (string.isEmpty()) {
+QVERIFY(goo->toStr().empty());
+QCOMPARE(goo->getLength(), 0);
+} else {
+QVERIFY(goo->hasUnicodeMarker());
+QCOMPARE(goo->getLength(), string.length() * 2 + 2);
+QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, 
goo->getLength() - 2));
+}
 
 delete goo;
 }
diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc
index c60876da..a2971adc 100644
--- a/qt6/src/poppler-private.cc
+++ b/qt6/src/poppler-private.cc
@@ -9,6 +9,7 @@
  * Copyright (C) 2018-2020 Adam Reichold 
  * Copyright (C) 2019, 2020 Oliver Sander 
  * Copyright (C) 2019 João Netto 
+ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, 

  * Inspired on code by
  * Copyright (C) 2004 by Albert Astals Cid 
  * Copyright (C) 2004 by Enrico Ros 
@@ -115,6 +116,9 @@ QString UnicodeParsedString(const std::string )
 
 GooString *QStringToUnicodeGooString(const QString )
 {
+if (s.isEmpty()) {
+return new GooString();
+}
 int len = s.length() * 2 + 2;
 char *cstring = (char *)gmallocn(len, sizeof(char));
 cstring[0] = (char)0xfe;
diff --git a/qt6/tests/check_strings.cpp b/qt6/tests/check_strings.cpp
index c887105c..fdd2f703 100644
--- a/qt6/tests/check_strings.cpp
+++ b/qt6/tests/check_strings.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010, 2011, Pino Toscano 
+ * Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, 

  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -189,9 +190,14 @@ void TestStrings::check_QStringToUnicodeGooString()
 QFETCH(QByteArray, result);
 
 GooString *goo = Poppler::QStringToUnicodeGooString(string);
-QVERIFY(goo->hasUnicodeMarker());
-QCOMPARE(goo->getLength(), string.length() * 2 + 2);
-QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, 
goo->getLength() - 2));
+if (string.isEmpty()) {
+QVERIFY(goo->toStr().empty());
+QCOMPARE(goo->getLength(), 0);
+} else {
+QVERIFY(goo->hasUnicodeMarker());
+QCOMPARE(goo->getLength(), string.length() * 2 + 2);
+QCOMPARE(result, QByteArray::fromRawData(goo->c_str() + 2, 
goo->getLength() - 2));
+}
 
 delete goo;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/PSOutputDev.cc

2021-04-14 Thread GitLab Mirror
 poppler/PSOutputDev.cc |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit be9960e86db051a4eabf30e0ab216168b8ce7b59
Author: Albert Astals Cid 
Date:   Wed Apr 14 00:02:11 2021 +0200

PSOutputDev::setupResources: Fix infinite recursion call on broken files

Issue #1065

diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index bb50080a..9ce6648f 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1828,8 +1828,17 @@ void PSOutputDev::setupResources(Dict *resDict)
 // process the XObject's resource dictionary
 Object xObj = xObjDict.dictGetVal(i);
 if (xObj.isStream()) {
-Object resObj = xObj.streamGetDict()->lookup("Resources");
+Ref resObjRef;
+Object resObj = xObj.streamGetDict()->lookup("Resources", 
);
 if (resObj.isDict()) {
+if (resObjRef != Ref::INVALID()) {
+const int numObj = resObjRef.num;
+if (resourceIDs.find(numObj) != resourceIDs.end()) 
{
+error(errSyntaxError, -1, "loop in Resources 
(numObj: {0:d})", numObj);
+continue;
+}
+resourceIDs.insert(numObj);
+}
 setupResources(resObj.getDict());
 }
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler