Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master_github
Browse files Browse the repository at this point in the history
  • Loading branch information
tsdgeos committed Apr 22, 2024
2 parents 281c516 + ad67d43 commit 720883d
Show file tree
Hide file tree
Showing 60 changed files with 1,023 additions and 335 deletions.
26 changes: 11 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ build_clang16_libcpp:
- cp "$srcdir/.clang-tidy" .
- run-clang-tidy-16

build_ubuntu_20_04:
build_ubuntu_22_04:
stage: build
image: ubuntu:20.04
image: ubuntu:22.04
before_script:
- apt-get update
- apt-get install --yes --no-install-recommends build-essential cmake ninja-build libjpeg-dev libopenjp2-7-dev qtbase5-dev gobject-introspection libglib2.0-dev libgtk-3-dev libgirepository1.0-dev libnss3-dev ca-certificates libcurl4-nss-dev liblcms2-dev libboost-container-dev libtiff-dev wget p7zip-full git
- wget -r -l1 -np "https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_620/qt.qt6.620.gcc_64/" -A "6.2.0-0-*qtbase-Linux-RHEL_8_2-GCC-Linux-RHEL_8_2-X86_64.7z"
- 7z x download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_620/qt.qt6.620.gcc_64/6.2.0-0-*qtbase-Linux-RHEL_8_2-GCC-Linux-RHEL_8_2-X86_64.7z
- wget -r -l1 -np "https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_620/qt.qt6.620.gcc_64/" -A "6.2.0-0-*icu-linux-Rhel7.2-x64.7z"
- 7z x download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_620/qt.qt6.620.gcc_64/6.2.0-0-*icu-linux-Rhel7.2-x64.7z
- apt-get install --yes --no-install-recommends build-essential cmake ninja-build libjpeg-dev libopenjp2-7-dev qtbase5-dev gobject-introspection libglib2.0-dev libgtk-3-dev libgirepository1.0-dev libnss3-dev ca-certificates libcurl4-nss-dev liblcms2-dev libboost-container-dev libtiff-dev wget p7zip-full git qt6-base-dev
script:
- git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data
- mkdir -p build && cd build
Expand Down Expand Up @@ -109,17 +105,17 @@ build_clazy_fedora40:
- CC=clang-18 CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -G Ninja ..
- CLAZY_CHECKS="level0,level1,level2,isempty-vs-count,qhash-with-char-pointer-key,tr-non-literal,no-non-pod-global-static" ninja -j ${FDO_CI_CONCURRENT}

build_qt5_android:
build_qt5_android_qt515:
stage: build
image: kdeorg/android-sdk
image: invent-registry.kde.org/sysadmin/ci-images/android-qt515
before_script:
- echo "workaround for ECM Android toolchain wanting all binaries to be shared libraries"
- sed -i -e 's/<LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>/<LINK_FLAGS>/g' /opt/nativetooling/share/ECM/toolchain/Android.cmake
script:
- mkdir -p build && cd build
- 'ANDROID_ARCH_ABI=arm64-v8a cmake -G Ninja ..
- 'ANDROID_ARCH_ABI=armeabi-v7a cmake -G Ninja ..
-DCMAKE_ANDROID_API=28
-DCMAKE_PREFIX_PATH="/opt/Qt/;/opt/kdeandroid-arm64/"
-DCMAKE_PREFIX_PATH="/home/user/android-arm-clang"
-DCMAKE_BUILD_TYPE=debug
-DCMAKE_POSITION_INDEPENDENT_CODE=OFF
-DENABLE_DCTDECODER=unmaintained
Expand All @@ -135,17 +131,17 @@ build_qt5_android:
-DCMAKE_TOOLCHAIN_FILE=/opt/nativetooling/share/ECM/toolchain/Android.cmake'
- ninja -j ${FDO_CI_CONCURRENT}

build_qt5_android_generic:
build_qt5_android_qt515_generic:
stage: build
image: kdeorg/android-sdk
image: invent-registry.kde.org/sysadmin/ci-images/android-qt515
before_script:
- echo "workaround for ECM Android toolchain wanting all binaries to be shared libraries"
- sed -i -e 's/<LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>/<LINK_FLAGS>/g' /opt/nativetooling/share/ECM/toolchain/Android.cmake
script:
- mkdir -p build && cd build
- 'ANDROID_ARCH_ABI=arm64-v8a cmake -G Ninja ..
- 'ANDROID_ARCH_ABI=armeabi-v7a cmake -G Ninja ..
-DCMAKE_ANDROID_API=28
-DCMAKE_PREFIX_PATH="/opt/Qt/;/opt/kdeandroid-arm64/"
-DCMAKE_PREFIX_PATH="/home/user/android-arm-clang"
-DCMAKE_BUILD_TYPE=debug
-DCMAKE_POSITION_INDEPENDENT_CODE=OFF
-DENABLE_DCTDECODER=unmaintained
Expand Down
22 changes: 12 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR)

project(poppler)

Expand Down Expand Up @@ -40,7 +40,7 @@ if (ECM_FOUND)
endif()

set(POPPLER_MAJOR_VERSION "24")
set(POPPLER_MINOR_VERSION_STRING "03")
set(POPPLER_MINOR_VERSION_STRING "05")
# We want the string version to have 08 but the integer version can't have a leading 0 since otherwise it's considered octal
# So strip a leading 0 if found in POPPLER_MINOR_VERSION_STRING and store the result in POPPLER_MINOR_VERSION
string(REGEX REPLACE "^0?(.+)$" "\\1" POPPLER_MINOR_VERSION "${POPPLER_MINOR_VERSION_STRING}")
Expand Down Expand Up @@ -142,10 +142,10 @@ set(TEXTOUT_WORD_LIST ON)

# setting the minimum required versions for some components
set(CAIRO_VERSION "1.16.0")
set(GLIB_REQUIRED "2.64")
set(GLIB_REQUIRED "2.72")
set(GTK_REQUIRED "3.24")
set(GDK_PIXBUF_REQUIRED "2.40")
set(FREETYPE_VERSION "2.10")
set(FREETYPE_VERSION "2.11")
set(FONTCONFIG_VERSION "2.13")

find_package(Freetype ${FREETYPE_VERSION} REQUIRED)
Expand All @@ -164,9 +164,9 @@ macro(find_soft_mandatory_package _enable_option _package_name _package_version)
endif()
endmacro()

find_soft_mandatory_package(ENABLE_NSS3 NSS3 3.68)
find_soft_mandatory_package(ENABLE_NSS3 NSS3 3.98)
find_soft_mandatory_package(ENABLE_GPGME Gpgmepp 1.19)
find_soft_mandatory_package(ENABLE_LIBTIFF TIFF 4.1)
find_soft_mandatory_package(ENABLE_LIBTIFF TIFF 4.3)

macro_optional_find_package(JPEG)
macro_optional_find_package(PNG)
Expand Down Expand Up @@ -208,7 +208,7 @@ else()
message(FATAL_ERROR "Invalid ENABLE_DCTDECODER value.")
endif()

set(QT5_VERSION "5.12") # Update QT_DISABLE_DEPRECATED_BEFORE in qt5/CMakeLists.txt when changing this
set(QT5_VERSION "5.15")
find_soft_mandatory_package(ENABLE_QT5 Qt5Core ${QT5_VERSION})
find_soft_mandatory_package(ENABLE_QT5 Qt5Gui ${QT5_VERSION})
find_soft_mandatory_package(ENABLE_QT5 Qt5Xml ${QT5_VERSION})
Expand All @@ -225,7 +225,7 @@ find_soft_mandatory_package(ENABLE_QT6 Qt6Test ${QT6_VERSION})
# Check for Cairo rendering backend
macro_optional_find_package(Cairo ${CAIRO_VERSION})

find_package(Boost 1.71.0)
find_package(Boost 1.74.0)
if(Boost_FOUND)
set(USE_BOOST_HEADERS ON)
elseif(ENABLE_BOOST)
Expand All @@ -247,7 +247,7 @@ if(CAIRO_FOUND)
if(ENABLE_GLIB)
if(ENABLE_GOBJECT_INTROSPECTION)
# Check for introspection
macro_optional_find_package(GObjectIntrospection 1.64.0)
macro_optional_find_package(GObjectIntrospection 1.72.0)
set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND})
endif()
set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED")
Expand Down Expand Up @@ -614,7 +614,7 @@ ADD_GPERF_FILE(TimesItalicWidths)
ADD_GPERF_FILE(TimesRomanWidths)
ADD_GPERF_FILE(ZapfDingbatsWidths)

set(POPPLER_SOVERSION_NUMBER "135")
set(POPPLER_SOVERSION_NUMBER "136")

set(LINKER_SCRIPT "${CMAKE_BINARY_DIR}/libpoppler.map")
configure_file(
Expand Down Expand Up @@ -692,6 +692,7 @@ if(ENABLE_UNSTABLE_API_ABI_HEADERS)
poppler/GfxState_helpers.h
poppler/GlobalParams.h
poppler/Hints.h
poppler/HashAlgorithm.h
poppler/JArithmeticDecoder.h
poppler/JBIG2Stream.h
poppler/JSInfo.h
Expand Down Expand Up @@ -719,6 +720,7 @@ if(ENABLE_UNSTABLE_API_ABI_HEADERS)
poppler/PSTokenizer.h
poppler/Rendition.h
poppler/CertificateInfo.h
poppler/SignatureInfo.h
poppler/Stream-CCITT.h
poppler/Stream.h
poppler/StructElement.h
Expand Down
16 changes: 16 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Release 24.04.0:
core:
* Optimize page text extraction speed
* Fix clipping path handling in some files. Issue #739
* Fix regression in text selection
* Fix text search across lines between paragraphs

qt6:
* Fix crash in SoundObject::data

utils:
* pdfsig: Add Catalan translation

build system:
* Build code as C++20

Release 24.03.0:
core:
* Fix opening some malformed files. Issue #1447
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindNSS3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ include(FindPackageHandleStandardArgs)

find_package(PkgConfig REQUIRED)

pkg_check_modules(NSS3 IMPORTED_TARGET "nss>=3.49")
pkg_check_modules(NSS3 IMPORTED_TARGET "nss>=3.98")

find_package_handle_standard_args(NSS3 DEFAULT_MSG NSS3_LIBRARIES NSS3_CFLAGS)
2 changes: 1 addition & 1 deletion cpp/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "Poppler CPP"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 24.03.0
PROJECT_NUMBER = 24.04.0

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
3 changes: 2 additions & 1 deletion cpp/poppler-global.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2021, 2022, Albert Astals Cid <[email protected]>
* Copyright (C) 2022, Tobias C. Berner <[email protected]>
* Copyright (C) 2022, Oliver Sander <[email protected]>
* Copyright (C) 2024, [email protected]
*
* 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
Expand Down Expand Up @@ -98,7 +99,7 @@ typedef unsigned int /* time_t */ time_type;
# pragma warning(push)
# pragma warning(disable : 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
#endif
class POPPLER_CPP_EXPORT ustring : public std::basic_string<unsigned short>
class POPPLER_CPP_EXPORT ustring : public std::basic_string<char16_t>
{
public:
ustring();
Expand Down
6 changes: 4 additions & 2 deletions cpp/poppler-private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2017-2019 Albert Astals Cid <[email protected]>
* Copyright (C) 2018 Suzuki Toshiya <[email protected]>
* Copyright (C) 2020 Adam Reichold <[email protected]>
* Copyright (C) 2024 Oliver Sander <[email protected]>
*
* 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
Expand All @@ -26,6 +27,7 @@

#include "GooString.h"
#include "Page.h"
#include "UTF.h"

#include <ctime>
#include <iostream>
Expand Down Expand Up @@ -63,8 +65,8 @@ ustring detail::unicode_GooString_to_ustring(const GooString *str)
const char *data = str->c_str();
const int len = str->getLength();

const bool is_unicodeLE = str->hasUnicodeMarkerLE();
const bool is_unicode = str->hasUnicodeMarker() || is_unicodeLE;
const bool is_unicodeLE = hasUnicodeByteOrderMarkLE(str->toStr());
const bool is_unicode = hasUnicodeByteOrderMark(str->toStr()) || is_unicodeLE;
int i = is_unicode ? 2 : 0;
ustring::size_type ret_len = len - i;
if (is_unicode) {
Expand Down
12 changes: 6 additions & 6 deletions glib/poppler-document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2016 Jakub Alba <[email protected]>
* Copyright (C) 2018, 2019, 2021, 2022 Marek Kasik <[email protected]>
* Copyright (C) 2019 Masamichi Hosoda <[email protected]>
* Copyright (C) 2019, 2021 Oliver Sander <[email protected]>
* Copyright (C) 2019, 2021, 2024 Oliver Sander <[email protected]>
* Copyright (C) 2020, 2022 Albert Astals Cid <[email protected]>
* Copyright (C) 2021 André Guerreiro <[email protected]>
* Copyright (C) 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
Expand Down Expand Up @@ -1099,9 +1099,9 @@ char *_poppler_goo_string_to_utf8(const GooString *s)

char *result;

if (s->hasUnicodeMarker()) {
if (hasUnicodeByteOrderMark(s->toStr())) {
result = g_convert(s->c_str() + 2, s->getLength() - 2, "UTF-8", "UTF-16BE", nullptr, nullptr, nullptr);
} else if (s->hasUnicodeMarkerLE()) {
} else if (hasUnicodeByteOrderMarkLE(s->toStr())) {
result = g_convert(s->c_str() + 2, s->getLength() - 2, "UTF-8", "UTF-16LE", nullptr, nullptr, nullptr);
} else {
int len;
Expand Down Expand Up @@ -1139,8 +1139,8 @@ static GooString *_poppler_goo_string_from_utf8(const gchar *src)
GooString *result = new GooString(utf16, outlen);
g_free(utf16);

if (!result->hasUnicodeMarker()) {
result->prependUnicodeMarker();
if (!hasUnicodeByteOrderMark(result->toStr())) {
prependUnicodeByteOrderMark(result->toNonConstStr());
}

return result;
Expand Down Expand Up @@ -3733,7 +3733,7 @@ gboolean _poppler_convert_pdf_date_to_gtime(const GooString *date, time_t *gdate
gchar *date_string;
gboolean retval;

if (date->hasUnicodeMarker()) {
if (hasUnicodeByteOrderMark(date->toStr())) {
date_string = g_convert(date->c_str() + 2, date->getLength() - 2, "UTF-8", "UTF-16BE", nullptr, nullptr, nullptr);
} else {
date_string = g_strndup(date->c_str(), date->getLength());
Expand Down
9 changes: 5 additions & 4 deletions glib/poppler-form-field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2020 Oliver Sander <[email protected]>
* Copyright (C) 2021 André Guerreiro <[email protected]>
* Copyright (C) 2021, 2023 Marek Kasik <[email protected]>
* Copyright (C) 2023 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
* Copyright (C) 2023, 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
*
* 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
Expand Down Expand Up @@ -449,8 +449,9 @@ static PopplerSignatureInfo *_poppler_form_field_signature_validate(PopplerFormF

sig_field = static_cast<FormFieldSignature *>(field->widget->getField());

sig_info = sig_field->validateSignature(flags & POPPLER_SIGNATURE_VALIDATION_FLAG_VALIDATE_CERTIFICATE, force_revalidation, -1, flags & POPPLER_SIGNATURE_VALIDATION_FLAG_WITHOUT_OCSP_REVOCATION_CHECK,
flags & POPPLER_SIGNATURE_VALIDATION_FLAG_USE_AIA_CERTIFICATE_FETCH);
sig_info = sig_field->validateSignatureAsync(flags & POPPLER_SIGNATURE_VALIDATION_FLAG_VALIDATE_CERTIFICATE, force_revalidation, -1, flags & POPPLER_SIGNATURE_VALIDATION_FLAG_WITHOUT_OCSP_REVOCATION_CHECK,
flags & POPPLER_SIGNATURE_VALIDATION_FLAG_USE_AIA_CERTIFICATE_FETCH, {});
CertificateValidationStatus certificateStatus = sig_field->validateSignatureResult();

poppler_sig_info = g_new0(PopplerSignatureInfo, 1);
switch (sig_info->getSignatureValStatus()) {
Expand All @@ -477,7 +478,7 @@ static PopplerSignatureInfo *_poppler_form_field_signature_validate(PopplerFormF
break;
}

switch (sig_info->getCertificateValStatus()) {
switch (certificateStatus) {
case CERTIFICATE_TRUSTED:
poppler_sig_info->cert_status = POPPLER_CERTIFICATE_TRUSTED;
break;
Expand Down
17 changes: 1 addition & 16 deletions goo/GooString.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2018 Adam Reichold <[email protected]>
// Copyright (C) 2018 Greg Knight <[email protected]>
// Copyright (C) 2019, 2022, 2023 Oliver Sander <[email protected]>
// Copyright (C) 2019, 2022-2024 Oliver Sander <[email protected]>
// Copyright (C) 2023 Even Rouault <[email protected]>
//
// To see a description of the changes please see the Changelog file that
Expand Down Expand Up @@ -620,18 +620,3 @@ std::string GooString::toLowerCase(const std::string &s)
lowerCase(newString);
return s;
}

void GooString::prependUnicodeMarker()
{
insert(0, "\xFE\xFF", 2);
}

bool GooString::startsWith(const char *prefix) const
{
return startsWith(toStr(), prefix);
}

bool GooString::endsWith(const char *suffix) const
{
return endsWith(toStr(), suffix);
}
23 changes: 5 additions & 18 deletions goo/GooString.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2019 Christophe Fergeau <[email protected]>
// Copyright (C) 2019 Tomoyuki Kubota <[email protected]>
// Copyright (C) 2019, 2020, 2022, 2023 Oliver Sander <[email protected]>
// Copyright (C) 2019, 2020, 2022-2024 Oliver Sander <[email protected]>
// Copyright (C) 2019 Hans-Ulrich Jüttner <[email protected]>
// Copyright (C) 2020 Thorsten Behrens <[email protected]>
// Copyright (C) 2022 Even Rouault <[email protected]>
Expand Down Expand Up @@ -156,11 +156,7 @@ class GooString : private std::string
void setChar(int i, char c) { (*this)[i] = c; }

// Clear string to zero length.
GooString *clear()
{
static_cast<std::string &>(*this).clear();
return this;
}
using std::string::clear;

// Append a character or string.
GooString *append(char c)
Expand Down Expand Up @@ -242,19 +238,10 @@ class GooString : private std::string
int cmpN(const char *sA, int n) const { return compare(0, n, sA); }

// Return true if strings starts with prefix
POPPLER_PRIVATE_EXPORT bool startsWith(const char *prefix) const;
// Return true if string ends with suffix
POPPLER_PRIVATE_EXPORT bool endsWith(const char *suffix) const;
using std::string::starts_with;

static bool startsWith(std::string_view str, std::string_view prefix) { return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), prefix); }
static bool endsWith(std::string_view str, std::string_view suffix) { return str.size() >= suffix.size() && 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix); }

bool hasUnicodeMarker() const { return hasUnicodeMarker(*this); }
static bool hasUnicodeMarker(const std::string &s) { return s.size() >= 2 && s[0] == '\xfe' && s[1] == '\xff'; }
bool hasUnicodeMarkerLE() const { return hasUnicodeMarkerLE(*this); }
static bool hasUnicodeMarkerLE(const std::string &s) { return s.size() >= 2 && s[0] == '\xff' && s[1] == '\xfe'; }

POPPLER_PRIVATE_EXPORT void prependUnicodeMarker();
// Return true if string ends with suffix
using std::string::ends_with;
};

#endif
Loading

0 comments on commit 720883d

Please sign in to comment.