[Git][java-team/xmlgraphics-commons][upstream] New upstream version 2.6

Mathieu Malaterre (@malat) gitlab at salsa.debian.org
Wed Nov 17 08:28:06 GMT 2021



Mathieu Malaterre pushed to branch upstream at Debian Java Maintainers / xmlgraphics-commons


Commits:
00cb2d9e by Mathieu Malaterre at 2021-11-17T09:27:43+01:00
New upstream version 2.6
- - - - -


16 changed files:

- NOTICE
- README
- build.properties
- build.xml
- + lib/build/hamcrest.core-1.1.0.jar
- + lib/build/mockito-core-1.8.5.jar
- + lib/build/objenesis-1.0.0.jar
- + lib/build/resolver-1.2.jar
- + lib/commons-io-1.3.1.jar
- + lib/commons-logging-1.0.4.jar
- pom.xml
- src/main/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java
- src/main/java/org/apache/xmlgraphics/xmp/XMPParser.java
- + src/test/java/org/apache/xmlgraphics/ps/FormGeneratorTestCase.java
- src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java
- src/test/java/org/apache/xmlgraphics/xmp/XMPParserTestCase.java


Changes:

=====================================
NOTICE
=====================================
@@ -1,5 +1,5 @@
 Apache XML Graphics Commons
-Copyright 2006-2019 The Apache Software Foundation
+Copyright 2006-2021 The Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).


=====================================
README
=====================================
@@ -1,4 +1,4 @@
-$Id: README 1868849 2019-10-24 07:50:09Z ssteiner $
+$Id: README 1885379 2021-01-12 09:32:59Z ssteiner $
 
 ==============================================================================
   APACHE XML GRAPHICS COMMONS  -  README
@@ -82,6 +82,11 @@ License labeling (according to http://www.apache.org/legal/3party.html):
 For more detailed info about the changes, please see:
 http://xmlgraphics.apache.org/commons/changes.html
 
+Version 2.6
+--------------
+
+Minor release to be used with FOP 2.6
+
 Version 2.4
 --------------
 


=====================================
build.properties
=====================================
@@ -34,7 +34,7 @@
 ## ===================================================================
 ## 3. Project specific properties
 
-version = 2.4
+version = 2.6
 
 ## Allows you to switch off the compilation of the internal image
 ## codecs which depend on Sun-private classes. Setting this to true


=====================================
build.xml
=====================================
@@ -25,7 +25,7 @@
 
   <property name="Name" value="Apache XML Graphics Commons"/>
   <property name="name" value="xmlgraphics-commons"/>
-  <property name="year" value="1999-2019"/>
+  <property name="year" value="1999-2021"/>
 
   <property name="javac.debug" value="on"/>
   <property name="javac.optimize" value="off"/>


=====================================
lib/build/hamcrest.core-1.1.0.jar
=====================================
Binary files /dev/null and b/lib/build/hamcrest.core-1.1.0.jar differ


=====================================
lib/build/mockito-core-1.8.5.jar
=====================================
Binary files /dev/null and b/lib/build/mockito-core-1.8.5.jar differ


=====================================
lib/build/objenesis-1.0.0.jar
=====================================
Binary files /dev/null and b/lib/build/objenesis-1.0.0.jar differ


=====================================
lib/build/resolver-1.2.jar
=====================================
Binary files /dev/null and b/lib/build/resolver-1.2.jar differ


=====================================
lib/commons-io-1.3.1.jar
=====================================
Binary files /dev/null and b/lib/commons-io-1.3.1.jar differ


=====================================
lib/commons-logging-1.0.4.jar
=====================================
Binary files /dev/null and b/lib/commons-logging-1.0.4.jar differ


=====================================
pom.xml
=====================================
@@ -4,7 +4,7 @@
 
   <groupId>org.apache.xmlgraphics</groupId>
   <artifactId>xmlgraphics-commons</artifactId>
-  <version>2.4</version>
+  <version>2.6</version>
   <name>${project.groupId}:${project.artifactId}</name>
   <description>XML Graphics Commons</description>
   <url>http://xmlgraphics.apache.org/commons/</url>
@@ -88,8 +88,6 @@
           <configuration>
             <source>${java.version}</source>
             <target>${java.version}</target>
-            <executable>${jdk.path}/bin/javac</executable>
-            <fork>true</fork>
           </configuration>
         </plugin>
         <plugin>
@@ -174,6 +172,33 @@
       </testResource>
     </testResources>
   </build>
+  
+  <profiles>
+    <profile>
+      <id>custom-javac</id>
+      <activation>
+        <property>
+          <name>jdk.path</name>
+        </property>
+      </activation>
+      <build>
+        <pluginManagement>
+          <plugins>
+            <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-compiler-plugin</artifactId>
+              <configuration>
+                <source>${java.version}</source>
+                <target>${java.version}</target>
+                <executable>${jdk.path}/bin/javac</executable>
+                <fork>true</fork>
+              </configuration>
+            </plugin>
+          </plugins>
+        </pluginManagement>
+      </build>
+    </profile>
+  </profiles>  
 
   <reporting>
     <plugins>


=====================================
src/main/java/org/apache/xmlgraphics/ps/ImageFormGenerator.java
=====================================
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: ImageFormGenerator.java 750418 2009-03-05 11:03:54Z vhennebert $ */
+/* $Id: ImageFormGenerator.java 1881060 2020-08-21 15:38:04Z ssteiner $ */
 
 package org.apache.xmlgraphics.ps;
 
@@ -114,7 +114,7 @@ public class ImageFormGenerator extends FormGenerator {
             return "/ASCII85Decode filter " + implicitFilter + " filter";
         } else {
             if (gen.getPSLevel() >= 3) {
-                return "/ASCII85Decode filter /FlateDecode filter";
+                return "/ASCII85Decode filter";
             } else {
                 return "/ASCII85Decode filter /RunLengthDecode filter";
             }
@@ -133,6 +133,12 @@ public class ImageFormGenerator extends FormGenerator {
             dataSource = "{ " + getDataName() + " i get /i i 1 add store } bind";
         } else {
             dataSource = getDataName();
+            if (gen.getPSLevel() >= 3) {
+                String implicitFilter = encoder.getImplicitFilter();
+                if (implicitFilter == null) {
+                    dataSource += " /FlateDecode filter";
+                }
+            }
         }
         AffineTransform at = new AffineTransform();
         at.scale(getDimensions().getWidth(), getDimensions().getHeight());


=====================================
src/main/java/org/apache/xmlgraphics/xmp/XMPParser.java
=====================================
@@ -15,12 +15,13 @@
  * limitations under the License.
  */
 
-/* $Id: XMPParser.java 1345683 2012-06-03 14:50:33Z gadams $ */
+/* $Id: XMPParser.java 1878394 2020-06-02 13:18:41Z ssteiner $ */
 
 package org.apache.xmlgraphics.xmp;
 
 import java.net.URL;
 
+import javax.xml.XMLConstants;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
@@ -54,6 +55,8 @@ public final class XMPParser {
      */
     public static Metadata parseXMP(Source src) throws TransformerException {
         TransformerFactory tFactory = TransformerFactory.newInstance();
+        tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+        tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
         Transformer transformer = tFactory.newTransformer();
         XMPHandler handler = createXMPHandler();
         SAXResult res = new SAXResult(handler);


=====================================
src/test/java/org/apache/xmlgraphics/ps/FormGeneratorTestCase.java
=====================================
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.ps;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.color.ColorSpace;
+
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.xmlgraphics.java2d.Dimension2DDouble;
+import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
+
+
+public class FormGeneratorTestCase {
+    @Test
+    public void testGeneratePaintProc() throws IOException {
+        Dimension2D dimension = new Dimension2DDouble(300, 500);
+        BufferedImage im = new BufferedImage(100, 75, BufferedImage.TYPE_INT_ARGB);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ImageFormGenerator formImageGen = new  ImageFormGenerator("form", "title", dimension, im, false);
+        PSGenerator gen = new PSGenerator(out);
+        formImageGen.generatePaintProc(gen);
+        String test = out.toString("UTF-8");
+
+        String  expected = "    form:Data 0 setfileposition\n"
+        + "[300 0 0 500 0 0] CT\n"
+        + "/DeviceRGB setcolorspace\n"
+        + "<<\n";
+        Assert.assertTrue(test.contains(expected));
+        Assert.assertTrue(test.contains("  /DataSource form:Data"));
+        Assert.assertTrue(test.contains("  /ImageMatrix [100 0 0 75 0 0]\n"));
+        Assert.assertTrue(test.contains("  /BitsPerComponent 8\n"));
+        Assert.assertTrue(test.contains("  /Height 75\n"));
+        Assert.assertTrue(test.contains("  /ImageType 1\n"));
+        Assert.assertTrue(test.contains("  /Decode [0 1 0 1 0 1]\n"));
+        Assert.assertTrue(test.contains(">> image\n"));
+        out.reset();
+        im = null;
+
+        Color c = Color.BLUE;
+        Dimension dimensionPX = new Dimension(200, 400);
+        ImageEncoder enco = ImageEncodingHelper.createRenderedImageEncoder(im);
+        ColorSpace cs = new NamedColorSpace("myColor", c);
+        formImageGen = new  ImageFormGenerator("form", "title", dimension, dimensionPX, enco, cs, false);
+        gen = new PSGenerator(out);
+        gen.setPSLevel(2);
+        formImageGen.generatePaintProc(gen);
+        test = out.toString("UTF-8");
+        expected = "    userdict /i 0 put\n"
+            + "[300 0 0 500 0 0] CT\n"
+            + "/DeviceGray setcolorspace\n"
+            + "<<\n";
+        Assert.assertTrue(test.contains(expected));
+        Assert.assertTrue(test.contains("  /DataSource { form:Data i get /i i 1 add store } bind\n"));
+        Assert.assertTrue(test.contains("  /ImageMatrix [200 0 0 400 0 0]\n"));
+        Assert.assertTrue(test.contains("  /Height 400\n"));
+        Assert.assertTrue(test.contains("  /BitsPerComponent 8\n"));
+        Assert.assertTrue(test.contains("  /ImageType 1\n"));
+        Assert.assertTrue(test.contains("  /Decode [0 1]\n"));
+        Assert.assertTrue(test.contains("  /Width 200\n"));
+        Assert.assertTrue(test.contains(">> image\n"));
+    }
+
+    @Test
+    public void testFlateDecodeCommand() throws IOException {
+        Dimension2D dimension = new Dimension2DDouble(300, 500);
+        BufferedImage im = new BufferedImage(100, 75, BufferedImage.TYPE_INT_ARGB);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ImageFormGenerator formImageGen = new ImageFormGenerator("form", "title", dimension, im, false);
+        PSGenerator gen = new PSGenerator(out);
+        formImageGen.generate(gen);
+        String test = out.toString("UTF-8");
+        Assert.assertTrue(test.contains("/ASCII85Decode filter\n"));
+        //FlateDecode at DataSource so executed on page load rather than document load so viewer loads faster
+        Assert.assertTrue(test.contains("/DataSource form:Data /FlateDecode filter\n"));
+    }
+}


=====================================
src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java
=====================================
@@ -15,10 +15,12 @@
  * limitations under the License.
  */
 
-/* $Id: Base64TestCase.java 1732018 2016-02-24 04:51:06Z gadams $ */
+/* $Id: Base64TestCase.java 1876186 2020-04-06 13:37:10Z ssteiner $ */
 
 package org.apache.xmlgraphics.util.io;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -31,15 +33,17 @@ import org.junit.Test;
 
 import static org.junit.Assert.fail;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * This test validates that the Base64 encoder/decoders work properly.
  *
- * @version $Id: Base64TestCase.java 1732018 2016-02-24 04:51:06Z gadams $
+ * @version $Id: Base64TestCase.java 1876186 2020-04-06 13:37:10Z ssteiner $
  */
 public class Base64TestCase {
 
     private void innerBase64Test(String action, URL in, URL ref) throws Exception {
-        InputStream inIS = in.openStream();
+        InputStream inIS = dos2Unix(in);
 
         if (action.equals("ROUND")) {
             ref = in;
@@ -47,7 +51,7 @@ public class Base64TestCase {
             fail("Bad action string");
         }
 
-        InputStream refIS = ref.openStream();
+        InputStream refIS = dos2Unix(ref);
 
         if (action.equals("ENCODE") || action.equals("ROUND")) {
             // We need to encode the incomming data
@@ -74,6 +78,21 @@ public class Base64TestCase {
         }
     }
 
+    private InputStream dos2Unix(URL url) throws IOException {
+        InputStream is = url.openStream();
+        byte[] data = IOUtils.toByteArray(is);
+        if (data.length > 1 && data[data.length - 1] == '\n') {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            for (byte b : data) {
+                if (b != '\r') {
+                    bos.write(b);
+                }
+            }
+            return new ByteArrayInputStream(bos.toByteArray());
+        }
+        return new ByteArrayInputStream(data);
+    }
+
     private void innerBase64Test(String action, String in, String ref) throws Exception {
         final String baseURL = "file:src/test/resources/org/apache/xmlgraphics/util/io/";
         innerBase64Test(action, new URL(baseURL + in), new URL(baseURL + ref));


=====================================
src/test/java/org/apache/xmlgraphics/xmp/XMPParserTestCase.java
=====================================
@@ -15,20 +15,25 @@
  * limitations under the License.
  */
 
-/* $Id: XMPParserTestCase.java 1732018 2016-02-24 04:51:06Z gadams $ */
+/* $Id: XMPParserTestCase.java 1878394 2020-06-02 13:18:41Z ssteiner $ */
 
 package org.apache.xmlgraphics.xmp;
 
+import java.io.StringReader;
 import java.net.URL;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
 
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
 import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
@@ -189,4 +194,18 @@ public class XMPParserTestCase {
         assertNull(title); //Empty value treated same as not existant
     }
 
+    @Test
+    public void testExternalDTD() {
+        String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                + "<!DOCTYPE root [\n<!ENTITY % remote SYSTEM \"http://127.0.0.1:9999/eval.xml\">\n%remote;]>\n"
+                + "<root></root>";
+        StreamSource streamSource = new StreamSource(new StringReader(payload));
+        String msg = "";
+        try {
+            XMPParser.parseXMP(streamSource);
+        } catch (TransformerException e) {
+            msg = e.getMessage();
+        }
+        assertTrue(msg, msg.contains("access is not allowed"));
+    }
 }



View it on GitLab: https://salsa.debian.org/java-team/xmlgraphics-commons/-/commit/00cb2d9e8a91138eb0cf56f484834f91e2b591da

-- 
View it on GitLab: https://salsa.debian.org/java-team/xmlgraphics-commons/-/commit/00cb2d9e8a91138eb0cf56f484834f91e2b591da
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20211117/15d805cb/attachment.htm>


More information about the pkg-java-commits mailing list