View | Details | Raw Unified | Return to bug 40676
Collapse All | Expand All

(-)src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java (+14 lines)
Lines 57-62 Link Here
57
57
58
    private static final int MAX_HIVAL = 255;
58
    private static final int MAX_HIVAL = 255;
59
59
60
    private boolean multipleFiltersAllowed = true;
61
60
    /**
62
    /**
61
     * Creates a new PDFImage from an Image instance.
63
     * Creates a new PDFImage from an Image instance.
62
     * @param image the image
64
     * @param image the image
Lines 293-297 Link Here
293
        return pdfCS;
295
        return pdfCS;
294
    }
296
    }
295
297
298
    /** {@inheritDoc} */
299
    public boolean multipleFiltersAllowed() {
300
        return multipleFiltersAllowed;
301
    }
302
303
    /**
304
     * Disallows multiple filters.
305
     */
306
    public void disallowMultipleFilters() {
307
        multipleFiltersAllowed = false;
308
    }
309
296
}
310
}
297
311
(-)src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java (+2 lines)
Lines 103-108 Link Here
103
            throw new RuntimeException("FlateFilter configuration error", e);
103
            throw new RuntimeException("FlateFilter configuration error", e);
104
        }
104
        }
105
        this.pdfFilter = flate;
105
        this.pdfFilter = flate;
106
        this.disallowMultipleFilters();
106
107
107
        // Handle transparency channel if applicable; note that for palette images the transparency is
108
        // Handle transparency channel if applicable; note that for palette images the transparency is
108
        // not TRANSLUCENT
109
        // not TRANSLUCENT
Lines 154-159 Link Here
154
            BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
155
            BitmapImage alphaMask = new BitmapImage("Mask:" + this.getKey(), image.getSize().getWidthPx(),
155
                    image.getSize().getHeightPx(), baos.toByteArray(), null);
156
                    image.getSize().getHeightPx(), baos.toByteArray(), null);
156
            alphaMask.setPDFFilter(transFlate);
157
            alphaMask.setPDFFilter(transFlate);
158
            alphaMask.disallowMultipleFilters();
157
            alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
159
            alphaMask.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
158
            softMask = doc.addImage(null, alphaMask).makeReference();
160
            softMask = doc.addImage(null, alphaMask).makeReference();
159
        }
161
        }
(-)src/java/org/apache/fop/pdf/AbstractPDFStream.java (-1 / +8 lines)
Lines 78-84 Link Here
78
     * from outside.
78
     * from outside.
79
     */
79
     */
80
    protected void setupFilterList() {
80
    protected void setupFilterList() {
81
        if (!getFilterList().isInitialized()) {
81
        if (multipleFiltersAllowed() && !getFilterList().isInitialized()) {
82
            getFilterList().addDefaultFilters(
82
            getFilterList().addDefaultFilters(
83
                getDocumentSafely().getFilterMap(),
83
                getDocumentSafely().getFilterMap(),
84
                getDefaultFilterName());
84
                getDefaultFilterName());
Lines 273-276 Link Here
273
        //nop: No default implicit filters
273
        //nop: No default implicit filters
274
    }
274
    }
275
275
276
    /**
277
     * Whether multiple filters can be applied.
278
     * @return true if multiple filters allowed
279
     */
280
    protected boolean multipleFiltersAllowed() {
281
        return true;
282
    }
276
}
283
}
(-)src/java/org/apache/fop/pdf/BitmapImage.java (-1 / +13 lines)
Lines 38-43 Link Here
38
    private String key;
38
    private String key;
39
    private PDFDocument pdfDoc;
39
    private PDFDocument pdfDoc;
40
    private PDFFilter pdfFilter;
40
    private PDFFilter pdfFilter;
41
    private boolean multipleFiltersAllowed = true;
41
42
42
    /**
43
    /**
43
     * Create a bitmap image.
44
     * Create a bitmap image.
Lines 215-220 Link Here
215
    public void setPDFFilter(PDFFilter pdfFilter) {
216
    public void setPDFFilter(PDFFilter pdfFilter) {
216
        this.pdfFilter = pdfFilter;
217
        this.pdfFilter = pdfFilter;
217
    }
218
    }
218
}
219
220
    /** {@inheritDoc} */
221
    public boolean multipleFiltersAllowed() {
222
        return multipleFiltersAllowed;
223
    }
219
224
225
    /**
226
     * Disallows multiple filters.
227
     */
228
    public void disallowMultipleFilters() {
229
        multipleFiltersAllowed = false;
230
    }
220
231
232
}
(-)src/java/org/apache/fop/pdf/PDFImageXObject.java (+5 lines)
Lines 166-169 Link Here
166
        return pdfimage.getFilterHint();
166
        return pdfimage.getFilterHint();
167
    }
167
    }
168
168
169
    /** {@inheritDoc} */
170
    protected boolean multipleFiltersAllowed() {
171
        return pdfimage.multipleFiltersAllowed();
172
    }
173
169
}
174
}
(-)src/java/org/apache/fop/pdf/AlphaRasterImage.java (+4 lines)
Lines 212-217 Link Here
212
        return null;
212
        return null;
213
    }
213
    }
214
214
215
    /** {@inheritDoc} */
216
    public boolean multipleFiltersAllowed() {
217
        return true;
218
    }
215
}
219
}
216
220
217
221
(-)src/java/org/apache/fop/pdf/PDFImage.java (+8 lines)
Lines 151-155 Link Here
151
     */
151
     */
152
    String getFilterHint();
152
    String getFilterHint();
153
153
154
    /**
155
     * Indicates whether multiple image filters are allowed; this is implemented because Adobe
156
     * Reader does not like multiple FlateDecode filters applied to an image even though that
157
     * allowed by the PDF spec; this is probable due to security concerns since many PDF malware
158
     * exploits, like zip bombs, make use of a chain of FlateDecode filters.
159
     */
160
    boolean multipleFiltersAllowed();
161
154
}
162
}
155
163

Return to bug 40676