Skip to content

Commit f5447c6

Browse files
committed
Merge remote-tracking branch 'origin/master' into master_github
2 parents 9ccc8d5 + 9ce35a2 commit f5447c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+393
-428
lines changed

Diff for: cpp/poppler-embedded-file.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (C) 2009-2011, Pino Toscano <[email protected]>
33
* Copyright (C) 2016 Jakub Alba <[email protected]>
44
* Copyright (C) 2018, 2020, 2022 Albert Astals Cid <[email protected]>
5+
* Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by

Diff for: cpp/poppler-font-private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (C) 2009, Pino Toscano <[email protected]>
33
* Copyright (C) 2015, Tamas Szekeres <[email protected]>
44
* Copyright (C) 2020, Suzuki Toshiya <[email protected]>
5-
* Copyright (C) 2021, 2024, Albert Astals Cid <[email protected]>
5+
* Copyright (C) 2021, 2024, 2025, Albert Astals Cid <[email protected]>
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by

Diff for: glib/poppler-annot.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright (C) 2007 Inigo Martinez <[email protected]>
44
* Copyright (C) 2009 Carlos Garcia Campos <[email protected]>
55
* Copyright (C) 2013 German Poo-Caamano <[email protected]>
6+
* Copyright (C) 2025 Albert Astals Cid <[email protected]>
7+
* Copyright (C) 2025 Markus Göllnitz <[email protected]>
68
*
79
* This program is free software; you can redistribute it and/or modify
810
* it under the terms of the GNU General Public License as published by
@@ -159,11 +161,11 @@ struct _PopplerAnnotSquareClass
159161
};
160162
struct _PopplerAnnotStamp
161163
{
162-
PopplerAnnot parent_instance;
164+
PopplerAnnotMarkup parent_instance;
163165
};
164166
struct _PopplerAnnotStampClass
165167
{
166-
PopplerAnnotClass parent_class;
168+
PopplerAnnotMarkupClass parent_class;
167169
};
168170

169171
G_DEFINE_TYPE(PopplerAnnot, poppler_annot, G_TYPE_OBJECT)
@@ -177,7 +179,7 @@ G_DEFINE_TYPE(PopplerAnnotScreen, poppler_annot_screen, POPPLER_TYPE_ANNOT)
177179
G_DEFINE_TYPE(PopplerAnnotLine, poppler_annot_line, POPPLER_TYPE_ANNOT_MARKUP)
178180
G_DEFINE_TYPE(PopplerAnnotCircle, poppler_annot_circle, POPPLER_TYPE_ANNOT_MARKUP)
179181
G_DEFINE_TYPE(PopplerAnnotSquare, poppler_annot_square, POPPLER_TYPE_ANNOT_MARKUP)
180-
G_DEFINE_TYPE(PopplerAnnotStamp, poppler_annot_stamp, POPPLER_TYPE_ANNOT)
182+
G_DEFINE_TYPE(PopplerAnnotStamp, poppler_annot_stamp, POPPLER_TYPE_ANNOT_MARKUP)
181183

182184
static PopplerAnnot *_poppler_create_annot(GType annot_type, Annot *annot)
183185
{

Diff for: glib/poppler-annot.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*
33
* Copyright (C) 2007 Inigo Martinez <[email protected]>
44
* Copyright (C) 2009 Carlos Garcia Campos <[email protected]>
5+
* Copyright (C) 2025 Markus Göllnitz <[email protected]>
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by
@@ -48,7 +49,7 @@ G_BEGIN_DECLS
4849
#define POPPLER_IS_ANNOT_FREE_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POPPLER_TYPE_ANNOT_FREE_TEXT))
4950

5051
#define POPPLER_TYPE_ANNOT_FILE_ATTACHMENT (poppler_annot_file_attachment_get_type())
51-
#define POPPLER_ANNOT_FILE_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_ANNOT_MARKUP, PopplerAnnotFileAttachment))
52+
#define POPPLER_ANNOT_FILE_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_ANNOT_FILE_ATTACHMENT, PopplerAnnotFileAttachment))
5253
#define POPPLER_IS_ANNOT_FILE_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POPPLER_TYPE_ANNOT_FILE_ATTACHMENT))
5354

5455
#define POPPLER_TYPE_ANNOT_MOVIE (poppler_annot_movie_get_type())

Diff for: glib/poppler-attachment.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* poppler-attachment.cc: glib wrapper for poppler
22
* Copyright (C) 2006, Red Hat, Inc.
3+
* Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
34
*
45
* This program is free software; you can redistribute it and/or modify
56
* it under the terms of the GNU General Public License as published by

Diff for: glib/poppler-form-field.cc

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright (C) 2021 André Guerreiro <[email protected]>
77
* Copyright (C) 2021, 2023 Marek Kasik <[email protected]>
88
* Copyright (C) 2023-2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
9+
* Copyright (C) 2025 Jan-Michael Brummer <[email protected]>
910
*
1011
* This program is free software; you can redistribute it and/or modify
1112
* it under the terms of the GNU General Public License as published by
@@ -1160,21 +1161,21 @@ PopplerSigningData *poppler_signing_data_new(void)
11601161

11611162
/* Grey background */
11621163
auto background_color = PopplerColor();
1163-
background_color.red = 0xEF;
1164-
background_color.green = 0xEF;
1165-
background_color.blue = 0xEF;
1164+
background_color.red = 0xEF00;
1165+
background_color.green = 0xEF00;
1166+
background_color.blue = 0xEF00;
11661167
poppler_signing_data_set_background_color(data, &background_color);
11671168

11681169
/* Red border color */
11691170
auto border_color = PopplerColor();
1170-
border_color.red = 0xFF;
1171+
border_color.red = 0xFFFF;
11711172
border_color.green = 0x00;
11721173
border_color.blue = 0x00;
11731174
poppler_signing_data_set_border_color(data, &border_color);
11741175

11751176
/* Red font color */
11761177
auto font_color = PopplerColor();
1177-
font_color.red = 0xFF;
1178+
font_color.red = 0xFFFF;
11781179
font_color.green = 0x00;
11791180
border_color.blue = 0x00;
11801181
poppler_signing_data_set_font_color(data, &font_color);

Diff for: glib/poppler-media.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* poppler-media.cc: glib interface to MediaRendition
22
*
33
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
4+
* Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
45
*
56
* This program is free software; you can redistribute it and/or modify
67
* it under the terms of the GNU General Public License as published by

Diff for: glib/poppler-structure-element.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* poppler-structure.cc: glib interface to poppler
22
*
33
* Copyright (C) 2013 Igalia S.L.
4-
* Copyright (C) 2018 Albert Astals Cid <[email protected]>
4+
* Copyright (C) 2018, 2025 Albert Astals Cid <[email protected]>
5+
* Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by
@@ -792,7 +793,7 @@ enum
792793
static PopplerTextSpan *text_span_poppler_text_span(const TextSpan &span)
793794
{
794795
PopplerTextSpan *new_span = g_slice_new0(PopplerTextSpan);
795-
if (GooString *text = span.getText()) {
796+
if (const GooString *text = span.getText()) {
796797
new_span->text = _poppler_goo_string_to_utf8(text);
797798
}
798799

Diff for: poppler/Annot.cc

+7-14
Original file line numberDiff line numberDiff line change
@@ -4530,7 +4530,7 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const Form *form, c
45304530
const GfxFont *font;
45314531
double fontSize;
45324532
int tfPos, tmPos;
4533-
bool freeText = false; // true if text should be freed before return
4533+
std::unique_ptr<GooString> textToFree;
45344534
std::unique_ptr<const GfxFont> fontToFree = nullptr;
45354535

45364536
//~ if there is no MK entry, this should use the existing content stream,
@@ -4604,12 +4604,11 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const Form *form, c
46044604
len = text->getLength();
46054605
}
46064606

4607-
GooString *newText = new GooString;
4607+
textToFree = std::make_unique<GooString>();
46084608
for (int i = 0; i < len; ++i) {
4609-
newText->append('*');
4609+
textToFree->append('*');
46104610
}
4611-
text = newText;
4612-
freeText = true;
4611+
text = textToFree.get();
46134612
}
46144613

46154614
// setup
@@ -4827,9 +4826,6 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const Form *form, c
48274826
if (flags & EmitMarkedContentDrawTextFlag) {
48284827
appearBuf->append("EMC\n");
48294828
}
4830-
if (freeText) {
4831-
delete text;
4832-
}
48334829

48344830
return true;
48354831
}
@@ -7625,12 +7621,9 @@ Annots::~Annots()
76257621
// AnnotAppearanceBuilder
76267622
//------------------------------------------------------------------------
76277623

7628-
AnnotAppearanceBuilder::AnnotAppearanceBuilder() : appearBuf(new GooString()) { }
7624+
AnnotAppearanceBuilder::AnnotAppearanceBuilder() : appearBuf { std::make_unique<GooString>() } { }
76297625

7630-
AnnotAppearanceBuilder::~AnnotAppearanceBuilder()
7631-
{
7632-
delete appearBuf;
7633-
}
7626+
AnnotAppearanceBuilder::~AnnotAppearanceBuilder() = default;
76347627

76357628
void AnnotAppearanceBuilder::append(const char *text)
76367629
{
@@ -7648,5 +7641,5 @@ void AnnotAppearanceBuilder::appendf(const char *fmt, ...) GOOSTRING_FORMAT
76487641

76497642
const GooString *AnnotAppearanceBuilder::buffer() const
76507643
{
7651-
return appearBuf;
7644+
return appearBuf.get();
76527645
}

Diff for: poppler/Annot.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ class AnnotAppearanceBuilder
630630
const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags = NoDrawTextFlags, const int nCombs = 0);
631631
void drawArrowPath(double x, double y, const Matrix &m, int orientation = 1);
632632

633-
GooString *appearBuf;
633+
std::unique_ptr<GooString> appearBuf;
634634
};
635635

636636
//------------------------------------------------------------------------

Diff for: poppler/CIDFontsWidthsBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// This file is licensed under the GPLv2 or later
66
//
77
// Copyright 2023 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
8-
// Copyright 2024 Albert Astals Cid <[email protected]>
8+
// Copyright 2024, 2025 Albert Astals Cid <[email protected]>
99
//========================================================================
1010

1111
#ifndef CIDFontsWidthsBuilder_H

Diff for: poppler/CMap.cc

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// Copyright (C) 2017 Adrian Johnson <[email protected]>
2020
// Copyright (C) 2018 Adam Reichold <[email protected]>
2121
// Copyright (C) 2019 LE GARREC Vincent <[email protected]>
22+
// Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
2223
//
2324
// To see a description of the changes please see the Changelog file that
2425
// came with your tarball or type make ChangeLog if you are building from git

Diff for: poppler/CairoFontEngine.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// Copyright (C) 2005-2007 Jeff Muizelaar <[email protected]>
1818
// Copyright (C) 2005, 2006 Kristian Høgsberg <[email protected]>
1919
// Copyright (C) 2005 Martin Kretzschmar <[email protected]>
20-
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017-2019, 2021, 2022, 2024 Albert Astals Cid <[email protected]>
20+
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017-2019, 2021, 2022, 2024, 2025 Albert Astals Cid <[email protected]>
2121
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <[email protected]>
2222
// Copyright (C) 2007 Koji Otani <[email protected]>
2323
// Copyright (C) 2008, 2009 Chris Wilson <[email protected]>

Diff for: poppler/CairoOutputDev.cc

+6-8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
// Copyright (C) 2024 Vincent Lefevre <[email protected]>
4343
// Copyright (C) 2024 Athul Raj Kollareth <[email protected]>
4444
// Copyright (C) 2024, 2025 Nelson Benítez León <[email protected]>
45+
// Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
4546
//
4647
// To see a description of the changes please see the Changelog file that
4748
// came with your tarball or type make ChangeLog if you are building from git
@@ -3142,21 +3143,18 @@ static bool colorMapHasIdentityDecodeMap(GfxImageColorMap *colorMap)
31423143

31433144
static cairo_status_t setMimeIdFromRef(cairo_surface_t *surface, const char *mime_type, const char *mime_id_prefix, Ref ref)
31443145
{
3145-
GooString *mime_id;
3146+
GooString mime_id;
31463147
char *idBuffer;
31473148
cairo_status_t status;
31483149

3149-
mime_id = new GooString;
3150-
31513150
if (mime_id_prefix) {
3152-
mime_id->append(mime_id_prefix);
3151+
mime_id.append(mime_id_prefix);
31533152
}
31543153

3155-
mime_id->appendf("{0:d}-{1:d}", ref.gen, ref.num);
3154+
mime_id.appendf("{0:d}-{1:d}", ref.gen, ref.num);
31563155

3157-
idBuffer = copyString(mime_id->c_str());
3158-
status = cairo_surface_set_mime_data(surface, mime_type, (const unsigned char *)idBuffer, mime_id->getLength(), gfree, idBuffer);
3159-
delete mime_id;
3156+
idBuffer = copyString(mime_id.c_str());
3157+
status = cairo_surface_set_mime_data(surface, mime_type, (const unsigned char *)idBuffer, mime_id.getLength(), gfree, idBuffer);
31603158
if (status) {
31613159
gfree(idBuffer);
31623160
}

Diff for: poppler/Catalog.cc

+32-8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
// Copyright (C) 2023 Ilaï Deutel <[email protected]>
4444
// Copyright (C) 2024 Hubert Figuiere <[email protected]>
4545
// Copyright (C) 2024, 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
46+
// Copyright (C) 2025 Aaron Nguyen <[email protected]>
4647
//
4748
// To see a description of the changes please see the Changelog file that
4849
// came with your tarball or type make ChangeLog if you are building from git
@@ -245,6 +246,30 @@ bool Catalog::initPageList()
245246
return false;
246247
}
247248

249+
// If the current Pages object lacks a Kids array but has a Parent dictionary, traverse up the hierarchy
250+
// until the root Pages object (one without a Parent) is found
251+
if (!obj.dictLookup("Kids").isArray() && obj.dictLookup("Parent").isDict()) {
252+
RefRecursionChecker seen;
253+
while (obj.isDict() && obj.dictLookup("Parent").isDict()) {
254+
Object parentDictObj = obj.dictLookup("Parent");
255+
256+
if (!seen.insert(pagesRef)) {
257+
error(errSyntaxError, -1, "Loop detected in Pages tree (numObj: {0:d})", pagesRef.num);
258+
break;
259+
}
260+
261+
if (parentDictObj.isDict()) {
262+
const Object &parentRefObj = obj.dictLookupNF("Parent");
263+
if (parentRefObj.isRef()) {
264+
pagesRef = parentRefObj.getRef();
265+
}
266+
obj = std::move(parentDictObj);
267+
} else {
268+
break;
269+
}
270+
}
271+
}
272+
248273
pages.clear();
249274
refPageMap.clear();
250275
attrsList.push_back(std::make_unique<PageAttrs>(nullptr, obj.getDict()));
@@ -562,7 +587,7 @@ void Catalog::addEmbeddedFile(GooFile *file, const std::string &fileName)
562587
embeddedFileNameTree = nullptr;
563588
}
564589

565-
GooString *Catalog::getJS(int i)
590+
std::string Catalog::getJS(int i)
566591
{
567592
Object obj;
568593
// getJSNameTree()->getValue(i) returns a shallow copy of the object so we
@@ -574,23 +599,22 @@ GooString *Catalog::getJS(int i)
574599
}
575600

576601
if (!obj.isDict()) {
577-
return nullptr;
602+
return {};
578603
}
579604
Object obj2 = obj.dictLookup("S");
580605
if (!obj2.isName()) {
581-
return nullptr;
606+
return {};
582607
}
583608
if (strcmp(obj2.getName(), "JavaScript") != 0) {
584-
return nullptr;
609+
return {};
585610
}
586611
obj2 = obj.dictLookup("JS");
587-
GooString *js = nullptr;
612+
std::string js;
588613
if (obj2.isString()) {
589-
js = new GooString(obj2.getString());
614+
js = obj2.getString()->toStr();
590615
} else if (obj2.isStream()) {
591616
Stream *stream = obj2.getStream();
592-
js = new GooString();
593-
stream->fillGooString(js);
617+
stream->fillString(js);
594618
}
595619
return js;
596620
}

Diff for: poppler/Catalog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class POPPLER_PRIVATE_EXPORT Catalog
196196
const GooString *getJSName(int i) { return getJSNameTree()->getName(i); }
197197

198198
// Get the i'th JavaScript script (at the Document level) in the document
199-
GooString *getJS(int i);
199+
std::string getJS(int i);
200200

201201
// Convert between page indices and page labels.
202202
bool labelToIndex(GooString *label, int *index);

Diff for: poppler/CharCodeToUnicode.cc

+4-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich
2929
// Copyright (C) 2018 Adam Reichold <[email protected]>
3030
// Copyright (C) 2019 <[email protected]>
31-
// Copyright (C) 2024 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
31+
// Copyright (C) 2024, 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]>
3232
//
3333
// To see a description of the changes please see the Changelog file that
3434
// came with your tarball or type make ChangeLog if you are building from git
@@ -205,7 +205,6 @@ bool CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data, int n
205205
int n1, n2, n3;
206206
CharCode i;
207207
CharCode maxCode, code1, code2;
208-
GooString *name;
209208
FILE *f;
210209

211210
bool ok = false;
@@ -215,16 +214,15 @@ bool CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data, int n
215214
while (pst->getToken(tok2, sizeof(tok2), &n2)) {
216215
if (!strcmp(tok2, "usecmap")) {
217216
if (tok1[0] == '/') {
218-
name = new GooString(tok1 + 1);
219-
if ((f = globalParams->findToUnicodeFile(name))) {
217+
GooString name { tok1 + 1 };
218+
if ((f = globalParams->findToUnicodeFile(&name))) {
220219
if (parseCMap1(&getCharFromFile, f, nBits)) {
221220
ok = true;
222221
}
223222
fclose(f);
224223
} else {
225-
error(errSyntaxError, -1, "Couldn't find ToUnicode CMap file for '{0:t}'", name);
224+
error(errSyntaxError, -1, "Couldn't find ToUnicode CMap file for '{0:s}'", name.c_str());
226225
}
227-
delete name;
228226
}
229227
pst->getToken(tok1, sizeof(tok1), &n1);
230228
} else if (!strcmp(tok2, "beginbfchar")) {

0 commit comments

Comments
 (0)