Auto sync2gitlab import of poppler-20.11.0-4.el8.src.rpm

This commit is contained in:
James Antill 2022-05-26 13:24:50 -04:00
parent 362013d0f8
commit 1f2d904ecd
9 changed files with 2685 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/poppler-20.11.0.tar.xz
/poppler-test-2009-05-13_0d2bfd4af4c76a3bac27ccaff793d9129df7b57a.tar.xz

1
EMPTY
View File

@ -1 +0,0 @@

View File

@ -0,0 +1,279 @@
From 0ab1f29d4ce315b0fca260c0e0f3007024d00342 Mon Sep 17 00:00:00 2001
From: Marek Kasik <mkasik@redhat.com>
Date: Tue, 28 Jan 2014 15:13:24 +0100
Subject: [PATCH] TextOutputDev: Respect orientation when selecting words
Take rotation into account when visiting selection.
This doesn't fix all problems (there are still problems
on line and block levels).
https://bugs.freedesktop.org/show_bug.cgi?id=16619
---
poppler/TextOutputDev.cc | 193 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 150 insertions(+), 43 deletions(-)
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 7c2ca78..e93908c 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -178,6 +178,12 @@
// to read the underlying image. Issue #157
#define glyphlessSelectionOpacity 0.4
+// Returns whether x is between a and b or equal to a or b.
+// a and b don't need to be sorted.
+#define XBetweenAB(x,a,b) (!(((x) > (a) && (x) > (b)) || \
+ ((x) < (a) && (x) < (b))) ? \
+ true : false)
+
namespace {
inline bool isAscii7(Unicode uchar)
@@ -4411,11 +4417,37 @@ void TextSelectionSizer::visitLine (TextLine *line,
PDFRectangle *rect;
double x1, y1, x2, y2, margin;
- margin = (line->yMax - line->yMin) / 8;
- x1 = line->edge[edge_begin];
- y1 = line->yMin - margin;
- x2 = line->edge[edge_end];
- y2 = line->yMax + margin;
+ switch (line->rot) {
+ default:
+ case 0:
+ margin = (line->yMax - line->yMin) / 8;
+ x1 = line->edge[edge_begin];
+ x2 = line->edge[edge_end];
+ y1 = line->yMin - margin;
+ y2 = line->yMax + margin;
+ break;
+ case 1:
+ margin = (line->xMax - line->xMin) / 8;
+ x1 = line->xMin - margin;
+ x2 = line->xMax + margin;
+ y1 = line->edge[edge_begin];
+ y2 = line->edge[edge_end];
+ break;
+ case 2:
+ margin = (line->yMax - line->yMin) / 8;
+ x1 = line->edge[edge_end];
+ x2 = line->edge[edge_begin];
+ y1 = line->yMin - margin;
+ y2 = line->yMax + margin;
+ break;
+ case 3:
+ margin = (line->xMax - line->xMin) / 8;
+ x1 = line->xMin - margin;
+ x2 = line->xMax + margin;
+ y1 = line->edge[edge_end];
+ y2 = line->edge[edge_begin];
+ break;
+ }
rect = new PDFRectangle(floor(x1 * scale), floor(y1 * scale), ceil(x2 * scale), ceil(y2 * scale));
list->push_back(rect);
@@ -4499,19 +4531,56 @@ void TextSelectionPainter::visitLine (TextLine *line,
{
double x1, y1, x2, y2, margin;
- margin = (line->yMax - line->yMin) / 8;
- x1 = floor(line->edge[edge_begin]);
- y1 = floor(line->yMin - margin);
- x2 = ceil(line->edge[edge_end]);
- y2 = ceil(line->yMax + margin);
+ switch (line->rot) {
+ default:
+ case 0:
+ margin = (line->yMax - line->yMin) / 8;
+ x1 = line->edge[edge_begin];
+ x2 = line->edge[edge_end];
+ y1 = line->yMin - margin;
+ y2 = line->yMax + margin;
+ break;
+ case 1:
+ margin = (line->xMax - line->xMin) / 8;
+ x1 = line->xMin - margin;
+ x2 = line->xMax + margin;
+ y1 = line->edge[edge_begin];
+ y2 = line->edge[edge_end];
+ break;
+ case 2:
+ margin = (line->yMax - line->yMin) / 8;
+ x1 = line->edge[edge_end];
+ x2 = line->edge[edge_begin];
+ y1 = line->yMin - margin;
+ y2 = line->yMax + margin;
+ break;
+ case 3:
+ margin = (line->xMax - line->xMin) / 8;
+ x1 = line->xMin - margin;
+ x2 = line->xMax + margin;
+ y1 = line->edge[edge_end];
+ y2 = line->edge[edge_begin];
+ break;
+ }
+
+ ctm.transform(x1, y1, &x1, &y1);
+ ctm.transform(x2, y2, &x2, &y2);
- ctm.transform(line->edge[edge_begin], line->yMin - margin, &x1, &y1);
- ctm.transform(line->edge[edge_end], line->yMax + margin, &x2, &y2);
+ if (x1 < x2) {
+ x1 = floor(x1);
+ x2 = ceil(x2);
+ } else {
+ x1 = ceil(x1);
+ x2 = floor(x2);
+ }
- x1 = floor(x1);
- y1 = floor(y1);
- x2 = ceil(x2);
- y2 = ceil(y2);
+ if (y1 < y2) {
+ y1 = floor(y1);
+ y2 = ceil(y2);
+ } else {
+ y1 = ceil(y1);
+ y2 = floor(y2);
+ }
ictm.transform(x1, y1, &x1, &y1);
ictm.transform(x2, y2, &x2, &y2);
@@ -4589,17 +4658,26 @@ void TextWord::visitSelection(TextSelectionVisitor *visitor,
void TextWord::visitSelection(TextSelectionVisitor *visitor, const PDFRectangle *selection, SelectionStyle style)
{
int i, begin, end;
- double mid;
+ double mid, s1, s2;
+
+ if (rot == 0 || rot == 2) {
+ s1 = selection->x1;
+ s2 = selection->x2;
+ } else {
+ s1 = selection->y1;
+ s2 = selection->y2;
+ }
begin = len;
end = 0;
for (i = 0; i < len; i++) {
mid = (edge[i] + edge[i + 1]) / 2;
- if (selection->x1 < mid || selection->x2 < mid)
- if (i < begin)
- begin = i;
- if (mid < selection->x1 || mid < selection->x2)
- end = i + 1;
+ if (XBetweenAB (mid, s1, s2)) {
+ if (i < begin)
+ begin = i;
+
+ end = i + 1;
+ }
}
/* Skip empty selection. */
@@ -4615,26 +4694,41 @@ void TextLine::visitSelection(TextSelectionVisitor *visitor,
TextWord *p, *begin, *end, *current;
int i, edge_begin, edge_end;
PDFRectangle child_selection;
+ double s1, s2, p_min, p_max;
+
+ if (rot == 0 || rot == 2) {
+ s1 = selection->x1;
+ s2 = selection->x2;
+ } else {
+ s1 = selection->y1;
+ s2 = selection->y2;
+ }
begin = nullptr;
end = nullptr;
current = nullptr;
for (p = words; p != nullptr; p = p->next) {
+ if (rot == 0 || rot == 2) {
+ p_min = p->xMin;
+ p_max = p->xMax;
+ } else {
+ p_min = p->yMin;
+ p_max = p->yMax;
+ }
+
if (blk->page->primaryLR) {
- if ((selection->x1 < p->xMax) || (selection->x2 < p->xMax))
- if (begin == nullptr)
- begin = p;
+ if (((s1 < p_max) || (s2 < p_max)) && begin == nullptr)
+ begin = p;
- if (((selection->x1 > p->xMin) || (selection->x2 > p->xMin)) && (begin != nullptr)) {
+ if (((s1 > p_min) || (s2 > p_min)) && begin != nullptr) {
end = p->next;
current = p;
}
} else {
- if ((selection->x1 > p->xMin) || (selection->x2 > p->xMin))
- if (begin == nullptr)
- begin = p;
+ if (((s1 > p_min) || (s2 > p_min)) && begin == nullptr)
+ begin = p;
- if (((selection->x1 < p->xMax) || (selection->x2 < p->xMax)) && (begin != nullptr)) {
+ if (((s1 < p_max) || (s2 < p_max)) && begin != nullptr) {
end = p->next;
current = p;
}
@@ -4650,23 +4740,41 @@ void TextLine::visitSelection(TextSelectionVisitor *visitor,
child_selection = *selection;
if (style == selectionStyleWord) {
- child_selection.x1 = begin ? begin->xMin : xMin;
- if (end && end->xMax != -1) {
- child_selection.x2 = current->xMax;
+ if (rot == 0 || rot == 2) {
+ child_selection.x1 = begin ? begin->xMin : xMin;
+ if (end && end->xMax != -1) {
+ child_selection.x2 = current->xMax;
+ } else {
+ child_selection.x2 = xMax;
+ }
} else {
- child_selection.x2 = xMax;
+ child_selection.y1 = begin ? begin->yMin : yMin;
+ if (end && end->yMax != -1) {
+ child_selection.y2 = current->yMax;
+ } else {
+ child_selection.y2 = yMax;
+ }
}
}
+ if (rot == 0 || rot == 2) {
+ s1 = child_selection.x1;
+ s2 = child_selection.x2;
+ } else {
+ s1 = child_selection.y1;
+ s2 = child_selection.y2;
+ }
+
edge_begin = len;
edge_end = 0;
for (i = 0; i < len; i++) {
double mid = (edge[i] + edge[i + 1]) / 2;
- if (child_selection.x1 < mid || child_selection.x2 < mid)
- if (i < edge_begin)
- edge_begin = i;
- if (mid < child_selection.x2 || mid < child_selection.x1)
- edge_end = i + 1;
+ if (XBetweenAB (mid, s1, s2)) {
+ if (i < edge_begin)
+ edge_begin = i;
+
+ edge_end = i + 1;
+ }
}
/* Skip empty selection. */
--
1.8.4.2

View File

@ -0,0 +1,205 @@
--- poppler/glib/poppler-document.cc
+++ poppler/glib/poppler-document.cc
@@ -3405,6 +3405,7 @@ PopplerFormField *poppler_document_get_f
unsigned fieldNum;
FormPageWidgets *widgets;
FormWidget *field;
+ PopplerFormField *formField;
FormWidget::decodeID(id, &pageNum, &fieldNum);
@@ -3417,8 +3418,14 @@ PopplerFormField *poppler_document_get_f
return nullptr;
field = widgets->getWidget(fieldNum);
- if (field)
- return _poppler_form_field_new(document, field);
+ if (field) {
+ formField = _poppler_form_field_new(document, field);
+ delete widgets;
+
+ return formField;
+ }
+
+ delete widgets;
return nullptr;
}
--- poppler/poppler/CairoOutputDev.cc
+++ poppler/poppler/CairoOutputDev.cc
@@ -2921,8 +2921,10 @@ void CairoOutputDev::setMimeData(GfxStat
// colorspace in stream dict may be different from colorspace in jpx
// data
- if (strKind == strJPX && colorSpace)
+ if (strKind == strJPX && colorSpace) {
+ delete colorSpace;
return;
+ }
// only embed mime data for gray, rgb, and cmyk colorspaces.
if (colorSpace) {
--- poppler/poppler/TextOutputDev.cc
+++ poppler/poppler/TextOutputDev.cc
@@ -1619,7 +1619,6 @@ TextBlock::~TextBlock()
void TextBlock::addWord(TextWord *word)
{
- pool->addWord(word);
if (xMin > xMax) {
xMin = word->xMin;
xMax = word->xMax;
@@ -1639,6 +1638,7 @@ void TextBlock::addWord(TextWord *word)
yMax = word->yMax;
}
}
+ pool->addWord(word);
}
void TextBlock::coalesce(const UnicodeMap *uMap, double fixedPitch)
@@ -3064,11 +3064,13 @@ void TextPage::coalesce(bool physLayout,
word0 = pool->getPool(startBaseIdx);
pool->setPool(startBaseIdx, word0->next);
word0->next = nullptr;
- blk = new TextBlock(this, rot);
- blk->addWord(word0);
fontSize = word0->fontSize;
minBase = maxBase = word0->base;
+
+ blk = new TextBlock(this, rot);
+ blk->addWord(word0);
+
colSpace1 = minColSpacing1 * fontSize;
colSpace2 = minColSpacing2 * fontSize;
lineSpace = maxLineSpacingDelta * fontSize;
@@ -3095,9 +3097,9 @@ void TextPage::coalesce(bool physLayout,
}
word1 = word1->next;
word2->next = nullptr;
+ newMinBase = word2->base;
blk->addWord(word2);
found = true;
- newMinBase = word2->base;
} else {
word0 = word1;
word1 = word1->next;
@@ -3123,9 +3125,9 @@ void TextPage::coalesce(bool physLayout,
}
word1 = word1->next;
word2->next = nullptr;
+ newMaxBase = word2->base;
blk->addWord(word2);
found = true;
- newMaxBase = word2->base;
} else {
word0 = word1;
word1 = word1->next;
@@ -3198,12 +3200,12 @@ void TextPage::coalesce(bool physLayout,
}
word1 = word1->next;
word2->next = nullptr;
- blk->addWord(word2);
if (word2->base < minBase) {
minBase = word2->base;
} else if (word2->base > maxBase) {
maxBase = word2->base;
}
+ blk->addWord(word2);
found = true;
break;
} else {
@@ -3246,12 +3248,12 @@ void TextPage::coalesce(bool physLayout,
}
word1 = word1->next;
word2->next = nullptr;
- blk->addWord(word2);
if (word2->base < minBase) {
minBase = word2->base;
} else if (word2->base > maxBase) {
maxBase = word2->base;
}
+ blk->addWord(word2);
found = true;
break;
} else {
--- poppler/poppler/XRef.cc
+++ poppler/poppler/XRef.cc
@@ -402,6 +402,7 @@ int XRef::reserve(int newSize)
void *p = greallocn_checkoverflow(entries, realNewSize, sizeof(XRefEntry));
if (p == nullptr) {
+ entries = nullptr;
return 0;
}
@@ -835,7 +836,6 @@ bool XRef::constructXRef(bool *wasRecons
int offset = 0;
resize(0); // free entries properly
- gfree(entries);
capacity = 0;
size = 0;
entries = nullptr;
--- poppler/test/pdf-inspector.cc
+++ poppler/test/pdf-inspector.cc
@@ -43,6 +43,7 @@ class PdfInspector
{
public:
PdfInspector();
+ ~PdfInspector();
void set_file_name(const char *file_name);
void load(const char *file_name);
@@ -108,6 +109,11 @@ PdfInspector::PdfInspector()
load(nullptr);
}
+PdfInspector::~PdfInspector(void)
+{
+ delete output;
+}
+
void PdfInspector::set_file_name(const char *file_name)
{
GtkWidget *widget;
--- poppler/utils/HtmlOutputDev.cc
+++ poppler/utils/HtmlOutputDev.cc
@@ -1337,6 +1337,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
// TODO can we calculate the resolution of the image?
if (!writer->init(f1, width, height, 72, 72)) {
error(errInternal, -1, "Can't init PNG for image '{0:t}'", fName);
+ delete fName;
delete writer;
fclose(f1);
return;
--- poppler/utils/pdftotext.cc
+++ poppler/utils/pdftotext.cc
@@ -329,6 +329,7 @@ int main(int argc, char *argv[])
fputs("<pre>\n", f);
if (f != stdout) {
fclose(f);
+ f = nullptr;
}
}
}
@@ -348,8 +349,9 @@ int main(int argc, char *argv[])
printWordBBox(f, doc, textOut, firstPage, lastPage);
}
}
- if (f != stdout) {
+ if (f != stdout && f != nullptr) {
fclose(f);
+ f = nullptr;
}
} else {
textOut = new TextOutputDev(textFileName->c_str(), physLayout, fixedPitch, rawOrder, htmlMeta, discardDiag);
@@ -390,7 +392,7 @@ int main(int argc, char *argv[])
fputs("</pre>\n", f);
fputs("</body>\n", f);
fputs("</html>\n", f);
- if (f != stdout) {
+ if (f != stdout && f != nullptr) {
fclose(f);
}
}

1055
poppler-0.66.0-nss.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
From 4f478daa6a9734b8f269a6586bdce2909844bb6f Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Wed, 23 Dec 2020 23:52:58 +0100
Subject: Fix opening files by some generators that are a bit broken
But Adobe opens it and it's easy to fix
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 66d3f04a..c36c747a 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -45,6 +45,7 @@
#include <cctype>
#include <climits>
#include <cfloat>
+#include <limits>
#include "goo/gfile.h"
#include "goo/gmem.h"
#include "Object.h"
@@ -793,8 +794,13 @@ bool XRef::readXRefStreamSection(Stream *xrefStr, const int *w, int first, int n
gen = (gen << 8) + c;
}
if (gen > INT_MAX) {
- error(errSyntaxError, -1, "Gen inside xref table too large (bigger than INT_MAX)");
- return false;
+ if (i == 0 && gen == std::numeric_limits<uint32_t>::max()) {
+ // workaround broken generators
+ gen = 65535;
+ } else {
+ error(errSyntaxError, -1, "Gen inside xref table too large (bigger than INT_MAX)");
+ return false;
+ }
}
if (entries[i].offset == -1) {
switch (type) {

View File

@ -0,0 +1,30 @@
--- poppler-20.11.0/glib/poppler-attachment.cc
+++ poppler-20.11.0/glib/poppler-attachment.cc
@@ -114,17 +114,21 @@ PopplerAttachment *_poppler_attachment_n
if (embFile->createDate()) {
priv->ctime = _poppler_convert_pdf_date_to_date_time(embFile->createDate());
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* This will overflow on dates from after 2038. This field is
- * deprecated, only kept for backward compatibility. */
- attachment->ctime = (GTime)g_date_time_to_unix(priv->ctime);
+ if (priv->ctime != NULL) {
+ /* This will overflow on dates from after 2038. This field is
+ * deprecated, only kept for backward compatibility. */
+ attachment->ctime = (GTime)g_date_time_to_unix(priv->ctime);
+ }
G_GNUC_END_IGNORE_DEPRECATIONS
}
if (embFile->modDate()) {
priv->mtime = _poppler_convert_pdf_date_to_date_time(embFile->modDate());
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- /* This will overflow on dates from after 2038. This field is
- * deprecated, only kept for backward compatibility. */
- attachment->mtime = (GTime)g_date_time_to_unix(priv->mtime);
+ if (priv->mtime != NULL) {
+ /* This will overflow on dates from after 2038. This field is
+ * deprecated, only kept for backward compatibility. */
+ attachment->mtime = (GTime)g_date_time_to_unix(priv->mtime);
+ }
G_GNUC_END_IGNORE_DEPRECATIONS
}

1077
poppler.spec Normal file

File diff suppressed because it is too large Load Diff

2
sources Normal file
View File

@ -0,0 +1,2 @@
SHA512 (poppler-20.11.0.tar.xz) = c8237e931ef20d939656e2600453fffb12a2beeafb273782b2069aec6e5915d8cc85136982b7eaf5956af30ce00da2faf84d86ffab47f725447dfbb9d6ffe335
SHA512 (poppler-test-2009-05-13_0d2bfd4af4c76a3bac27ccaff793d9129df7b57a.tar.xz) = f8ce114357043a893100de2d52ada8bd850148d19f0e8c889988ea97e9a92313f0545c0b88ef32a1ce7f0e9e58edc1a8c9066278c20b7718ca619913fd4bfb3c