diff options
-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 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java | 14 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java | 2 | ||||
-rw-r--r-- | status.xml | 3 |
8 files changed, 57 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(); + } + } diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index 36d58246f..46e8ebe95 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -57,6 +57,8 @@ public abstract class AbstractImageAdapter implements PDFImage { private static final int MAX_HIVAL = 255; + private boolean multipleFiltersAllowed = true; + /** * Creates a new PDFImage from an Image instance. * @param image the image @@ -293,5 +295,17 @@ public abstract class AbstractImageAdapter implements PDFImage { return pdfCS; } + /** {@inheritDoc} */ + public boolean multipleFiltersAllowed() { + return multipleFiltersAllowed; + } + + /** + * Disallows multiple filters. + */ + public void disallowMultipleFilters() { + multipleFiltersAllowed = false; + } + } diff --git a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java index 55264e2fe..b9f5e1d28 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java @@ -103,6 +103,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { throw new RuntimeException("FlateFilter configuration error", e);
}
this.pdfFilter = flate;
+ this.disallowMultipleFilters();
// Handle transparency channel if applicable; note that for palette images the transparency is
// not TRANSLUCENT
@@ -154,6 +155,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
image.getSize().getHeightPx(), baos.toByteArray(), null);
alphaMask.setPDFFilter(transFlate);
+ alphaMask.disallowMultipleFilters();
alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
softMask = doc.addImage(null, alphaMask).makeReference();
}
diff --git a/status.xml b/status.xml index 4046f9ec3..fb5330ca3 100644 --- a/status.xml +++ b/status.xml @@ -63,6 +63,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> <release version="FOP Trunk" date="TBD"> + <action context="Images" dev="GA" type="update" fixes-bug="40676" due-to="Luis Bernardo"> + Fix interoperability issue with Adobe reader regarding use of multiple filters. + </action> <action context="Code" dev="GA" type="fix"> Eliminate javadocs warnings. </action> |