diff options
author | Glenn Adams <gadams@apache.org> | 2012-06-24 17:53:17 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2012-06-24 17:53:17 +0000 |
commit | 6ebb1734ecae43bb804a59db72eb1a416a94afba (patch) | |
tree | 0d844944bd5810867b877970fe94bdd5af57c03d /src/java/org/apache/fop/pdf | |
parent | bf1401875c3aa097c5670de1da524b7a1318926f (diff) | |
download | xmlgraphics-fop-6ebb1734ecae43bb804a59db72eb1a416a94afba.tar.gz xmlgraphics-fop-6ebb1734ecae43bb804a59db72eb1a416a94afba.zip |
Bugzilla #40676: Fix interoperability issue with Adobe reader regarding use of multiple filters. Submitted by Luis Bernardo.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1353303 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r-- | src/java/org/apache/fop/pdf/AbstractPDFStream.java | 9 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/AlphaRasterImage.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/BitmapImage.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFImage.java | 8 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFImageXObject.java | 5 |
5 files changed, 38 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/pdf/AbstractPDFStream.java b/src/java/org/apache/fop/pdf/AbstractPDFStream.java index 0181728b8..0948a7d2b 100644 --- a/src/java/org/apache/fop/pdf/AbstractPDFStream.java +++ b/src/java/org/apache/fop/pdf/AbstractPDFStream.java @@ -78,7 +78,7 @@ public abstract class AbstractPDFStream extends PDFObject { * from outside. */ protected void setupFilterList() { - if (!getFilterList().isInitialized()) { + if (multipleFiltersAllowed() && !getFilterList().isInitialized()) { getFilterList().addDefaultFilters( getDocumentSafely().getFilterMap(), getDefaultFilterName()); @@ -273,4 +273,11 @@ public abstract class AbstractPDFStream extends PDFObject { //nop: No default implicit filters } + /** + * Whether multiple filters can be applied. + * @return true if multiple filters allowed + */ + protected boolean multipleFiltersAllowed() { + return true; + } } diff --git a/src/java/org/apache/fop/pdf/AlphaRasterImage.java b/src/java/org/apache/fop/pdf/AlphaRasterImage.java index 7272c5edd..250b5daa2 100644 --- a/src/java/org/apache/fop/pdf/AlphaRasterImage.java +++ b/src/java/org/apache/fop/pdf/AlphaRasterImage.java @@ -212,6 +212,10 @@ public class AlphaRasterImage implements PDFImage { return null; } + /** {@inheritDoc} */ + public boolean multipleFiltersAllowed() { + return true; + } } diff --git a/src/java/org/apache/fop/pdf/BitmapImage.java b/src/java/org/apache/fop/pdf/BitmapImage.java index 0979ddf9a..ac7af1dbd 100644 --- a/src/java/org/apache/fop/pdf/BitmapImage.java +++ b/src/java/org/apache/fop/pdf/BitmapImage.java @@ -38,6 +38,7 @@ public class BitmapImage implements PDFImage { private String key; private PDFDocument pdfDoc; private PDFFilter pdfFilter; + private boolean multipleFiltersAllowed = true; /** * Create a bitmap image. @@ -215,6 +216,17 @@ public class BitmapImage implements PDFImage { public void setPDFFilter(PDFFilter pdfFilter) { this.pdfFilter = pdfFilter; } -} + /** {@inheritDoc} */ + public boolean multipleFiltersAllowed() { + return multipleFiltersAllowed; + } + + /** + * Disallows multiple filters. + */ + public void disallowMultipleFilters() { + multipleFiltersAllowed = false; + } +} diff --git a/src/java/org/apache/fop/pdf/PDFImage.java b/src/java/org/apache/fop/pdf/PDFImage.java index e2b9e521c..38da60e7b 100644 --- a/src/java/org/apache/fop/pdf/PDFImage.java +++ b/src/java/org/apache/fop/pdf/PDFImage.java @@ -151,5 +151,13 @@ public interface PDFImage { */ String getFilterHint(); + /** + * Indicates whether multiple image filters are allowed; this is implemented because Adobe + * Reader does not like multiple FlateDecode filters applied to an image even though that + * allowed by the PDF spec; this is probable due to security concerns since many PDF malware + * exploits, like zip bombs, make use of a chain of FlateDecode filters. + */ + boolean multipleFiltersAllowed(); + } diff --git a/src/java/org/apache/fop/pdf/PDFImageXObject.java b/src/java/org/apache/fop/pdf/PDFImageXObject.java index acab4c19c..1c28cb2a7 100644 --- a/src/java/org/apache/fop/pdf/PDFImageXObject.java +++ b/src/java/org/apache/fop/pdf/PDFImageXObject.java @@ -166,4 +166,9 @@ public class PDFImageXObject extends PDFXObject { return pdfimage.getFilterHint(); } + /** {@inheritDoc} */ + protected boolean multipleFiltersAllowed() { + return pdfimage.multipleFiltersAllowed(); + } + } |