diff options
author | Mehdi Houshmand <mehdi@apache.org> | 2012-06-26 09:14:25 +0000 |
---|---|---|
committer | Mehdi Houshmand <mehdi@apache.org> | 2012-06-26 09:14:25 +0000 |
commit | 13a68b516babeccef8772be65b83b3de35e854e7 (patch) | |
tree | 3a88e836c8ea946307d9ab983c35f41d2ba88129 /src/java/org/apache/fop/pdf | |
parent | a97e0be88b38483a36aa5101df08f370a5f53433 (diff) | |
parent | 63f9e3bd728b7692e577b4889de051c80fc5178c (diff) | |
download | xmlgraphics-fop-13a68b516babeccef8772be65b83b3de35e854e7.tar.gz xmlgraphics-fop-13a68b516babeccef8772be65b83b3de35e854e7.zip |
Merged in trunk@1353397
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_URI_Unification@1353883 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/PDFFactory.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFImage.java | 8 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFImageXObject.java | 5 |
6 files changed, 40 insertions, 4 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/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index 39ddf7262..f6e9e255d 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -1641,8 +1641,8 @@ public class PDFFactory { FontFileReader reader = new FontFileReader(in); TTFSubSetFile subset = new TTFSubSetFile(); - byte[] subsetFont = subset.readFont(reader, - mbfont.getTTCName(), mbfont.getUsedGlyphs()); + subset.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs()); + byte[] subsetFont = subset.getFontSubset(); // Only TrueType CID fonts are supported now embeddedFont = new PDFTTFStream(subsetFont.length); 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(); + } + } |