https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8424
Bug ID: 8424
Summary: PDFInfo misses images whose width and height are on
separate lines
Product: Spamassassin
Version: 4.0.2
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: normal
Priority: P2
Component: Plugins
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: Undefined
Created attachment 6091
--> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6091&action=edit
the whole image description on one line. The plugin finds the image.
PDFInfo does not count an image in a PDF when the file writes the image's
width and height on separate lines, like this:
/Subtype /Image
/Width 300
/Height 300
Many PDF writers use this layout. For those files pdf_image_count() is 0,
and every rule that depends on image size (GMD_PDF_SQUARE, GMD_PDF_HORIZ,
GMD_PDF_VERT, pdf_image_size_range, pdf_pixel_coverage) cannot fire.
Cause:
The plugin reads the PDF one line at a time. The variables that hold the
width and height are declared inside that loop, so they start empty on
every line: the width is forgotten before the height is read on the next
line. An image is only counted when both values appear on the same line.
In lib/Mail/SpamAssassin/Plugin/PDFInfo.pm, the loop starts at line 295
and the declaration is at line 339:
295: while ($data =~ /([^\n]+)/g) {
...
339: my ($width, $height);
The values look meant to carry over between lines, because line 364
already resets them after each image is found:
364: $got_image = $height = $width = 0; # reset and check for next
image
Suggested fix:
Move the declaration "my ($width, $height);" from line 339 to just before
the loop at line 295. The existing reset at line 364 already clears the
values after each image.
To reproduce:
Two small test PDFs are attached. They are identical, a single 300x300
image, except for the layout of the image's dictionary:
pdfinfo-image-same-line.pdf /Width 300/Height 300 on one line
pdfinfo-image-split.pdf one entry per line
Attached to a message and run through "spamassassin -D pdfinfo -t", the
first logs "Found image in PDF ... 300 x 300" and fires GMD_PDF_SQUARE.
The second logs no image and GMD_PDF_SQUARE does not fire. With the fix
above, both find the image.
--
You are receiving this mail because:
You are the assignee for the bug.