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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 25 21:10:11 UTC 2020


 qt5/src/poppler-private.cc  |    4 ++--
 qt5/tests/check_strings.cpp |    9 +++++++++
 qt6/src/poppler-private.cc  |    4 ++--
 qt6/tests/check_strings.cpp |    9 +++++++++
 4 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit 2b8692a5a52a8cd997e70f7912ad7cedeb34891b
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Aug 25 23:05:51 2020 +0200

    qt: Clean as many null characters from the end as possible
    
    Not only one
    
    Fixes KDE bug #425791

diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 827a6345..84cc8c56 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -77,8 +77,8 @@ QString unicodeToQString(const Unicode *u, int len)
 {
     const UnicodeMap *utf8Map = globalParams->getUtf8Map();
 
-    // ignore the last character if it is 0x0
-    if ((len > 0) && (u[len - 1] == 0)) {
+    // ignore the last characters if they are 0x0
+    while ((len > 0) && (u[len - 1] == 0)) {
         --len;
     }
 
diff --git a/qt5/tests/check_strings.cpp b/qt5/tests/check_strings.cpp
index 948171f6..4c996c4f 100644
--- a/qt5/tests/check_strings.cpp
+++ b/qt5/tests/check_strings.cpp
@@ -114,6 +114,15 @@ void TestStrings::check_unicodeToQString_data()
         u[2] = 0x0;
         QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + 0") << u << l << QStringLiteral("封面");
     }
+    {
+        const int l = 4;
+        Unicode *u = new Unicode[l];
+        u[0] = 0x5c01;
+        u[1] = 0x9762;
+        u[2] = 0x0;
+        u[3] = 0x0;
+        QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + two 0") << u << l << QStringLiteral("封面");
+    }
 }
 
 void TestStrings::check_unicodeToQString()
diff --git a/qt6/src/poppler-private.cc b/qt6/src/poppler-private.cc
index 44a9a6dc..e7566500 100644
--- a/qt6/src/poppler-private.cc
+++ b/qt6/src/poppler-private.cc
@@ -77,8 +77,8 @@ QString unicodeToQString(const Unicode *u, int len)
 {
     const UnicodeMap *utf8Map = globalParams->getUtf8Map();
 
-    // ignore the last character if it is 0x0
-    if ((len > 0) && (u[len - 1] == 0)) {
+    // ignore the last characters if they are 0x0
+    while ((len > 0) && (u[len - 1] == 0)) {
         --len;
     }
 
diff --git a/qt6/tests/check_strings.cpp b/qt6/tests/check_strings.cpp
index fa7c6bab..c887105c 100644
--- a/qt6/tests/check_strings.cpp
+++ b/qt6/tests/check_strings.cpp
@@ -114,6 +114,15 @@ void TestStrings::check_unicodeToQString_data()
         u[2] = 0x0;
         QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + 0") << u << l << QStringLiteral("封面");
     }
+    {
+        const int l = 4;
+        Unicode *u = new Unicode[l];
+        u[0] = 0x5c01;
+        u[1] = 0x9762;
+        u[2] = 0x0;
+        u[3] = 0x0;
+        QTest::newRow("\xe5\xb0\x81\xe9\x9d\xa2 + two 0") << u << l << QStringLiteral("封面");
+    }
 }
 
 void TestStrings::check_unicodeToQString()


More information about the poppler mailing list