* from outside.
*/
protected void setupFilterList() {
- if (!getFilterList().isInitialized()) {
+ if (multipleFiltersAllowed() && !getFilterList().isInitialized()) {
getFilterList().addDefaultFilters(
getDocumentSafely().getFilterMap(),
getDefaultFilterName());
//nop: No default implicit filters
}
+ /**
+ * Whether multiple filters can be applied.
+ * @return true if multiple filters allowed
+ */
+ protected boolean multipleFiltersAllowed() {
+ return true;
+ }
}
return null;
}
+ /** {@inheritDoc} */
+ public boolean multipleFiltersAllowed() {
+ return true;
+ }
}
private String key;
private PDFDocument pdfDoc;
private PDFFilter pdfFilter;
+ private boolean multipleFiltersAllowed = true;
/**
* Create a bitmap image.
public void setPDFFilter(PDFFilter pdfFilter) {
this.pdfFilter = pdfFilter;
}
-}
+ /** {@inheritDoc} */
+ public boolean multipleFiltersAllowed() {
+ return multipleFiltersAllowed;
+ }
+
+ /**
+ * Disallows multiple filters.
+ */
+ public void disallowMultipleFilters() {
+ multipleFiltersAllowed = false;
+ }
+}
*/
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();
+
}
return pdfimage.getFilterHint();
}
+ /** {@inheritDoc} */
+ protected boolean multipleFiltersAllowed() {
+ return pdfimage.multipleFiltersAllowed();
+ }
+
}
private static final int MAX_HIVAL = 255;
+ private boolean multipleFiltersAllowed = true;
+
/**
* Creates a new PDFImage from an Image instance.
* @param image the image
return pdfCS;
}
+ /** {@inheritDoc} */
+ public boolean multipleFiltersAllowed() {
+ return multipleFiltersAllowed;
+ }
+
+ /**
+ * Disallows multiple filters.
+ */
+ public void disallowMultipleFilters() {
+ multipleFiltersAllowed = false;
+ }
+
}
throw new RuntimeException("FlateFilter configuration error", e);\r
}\r
this.pdfFilter = flate;\r
+ this.disallowMultipleFilters();\r
\r
// Handle transparency channel if applicable; note that for palette images the transparency is\r
// not TRANSLUCENT\r
BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),\r
image.getSize().getHeightPx(), baos.toByteArray(), null);\r
alphaMask.setPDFFilter(transFlate);\r
+ alphaMask.disallowMultipleFilters();\r
alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));\r
softMask = doc.addImage(null, alphaMask).makeReference();\r
}\r
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>