xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gad...@apache.org
Subject svn commit: r1353303 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/pdf/ src/java/org/apache/fop/render/pdf/
Date Sun, 24 Jun 2012 17:53:18 GMT
Author: gadams
Date: Sun Jun 24 17:53:17 2012
New Revision: 1353303

URL: http://svn.apache.org/viewvc?rev=1353303&view=rev
Log:
Bugzilla #40676: Fix interoperability issue with Adobe reader regarding use of multiple filters.
Submitted by Luis Bernardo.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AbstractPDFStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/BitmapImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImageXObject.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AbstractPDFStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AbstractPDFStream.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AbstractPDFStream.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AbstractPDFStream.java Sun Jun 24 17:53:17
2012
@@ -78,7 +78,7 @@ public abstract class AbstractPDFStream 
      * 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 
         //nop: No default implicit filters
     }
 
+    /**
+     * Whether multiple filters can be applied.
+     * @return true if multiple filters allowed
+     */
+    protected boolean multipleFiltersAllowed() {
+        return true;
+    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java Sun Jun 24 17:53:17
2012
@@ -212,6 +212,10 @@ public class AlphaRasterImage implements
         return null;
     }
 
+    /** {@inheritDoc} */
+    public boolean multipleFiltersAllowed() {
+        return true;
+    }
 }
 
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/BitmapImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/BitmapImage.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/BitmapImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/BitmapImage.java Sun Jun 24 17:53:17
2012
@@ -38,6 +38,7 @@ public class BitmapImage implements PDFI
     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 PDFI
     public void setPDFFilter(PDFFilter pdfFilter) {
         this.pdfFilter = pdfFilter;
     }
-}
 
+    /** {@inheritDoc} */
+    public boolean multipleFiltersAllowed() {
+        return multipleFiltersAllowed;
+    }
+
+    /**
+     * Disallows multiple filters.
+     */
+    public void disallowMultipleFilters() {
+        multipleFiltersAllowed = false;
+    }
 
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImage.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImage.java Sun Jun 24 17:53:17 2012
@@ -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();
+
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImageXObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImageXObject.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImageXObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFImageXObject.java Sun Jun 24 17:53:17
2012
@@ -166,4 +166,9 @@ public class PDFImageXObject extends PDF
         return pdfimage.getFilterHint();
     }
 
+    /** {@inheritDoc} */
+    protected boolean multipleFiltersAllowed() {
+        return pdfimage.multipleFiltersAllowed();
+    }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java Sun
Jun 24 17:53:17 2012
@@ -57,6 +57,8 @@ public abstract class AbstractImageAdapt
 
     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 AbstractImageAdapt
         return pdfCS;
     }
 
+    /** {@inheritDoc} */
+    public boolean multipleFiltersAllowed() {
+        return multipleFiltersAllowed;
+    }
+
+    /**
+     * Disallows multiple filters.
+     */
+    public void disallowMultipleFilters() {
+        multipleFiltersAllowed = false;
+    }
+
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java Sun Jun
24 17:53:17 2012
@@ -103,6 +103,7 @@ public class ImageRawPNGAdapter extends 
             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 
             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();
         }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1353303&r1=1353302&r2=1353303&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Jun 24 17:53:17 2012
@@ -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>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message