pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1842148 - /pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
Date Thu, 27 Sep 2018 19:32:07 GMT
Author: tilman
Date: Thu Sep 27 19:32:06 2018
New Revision: 1842148

URL: http://svn.apache.org/viewvc?rev=1842148&view=rev
Log:
PDFBOX-4325: parse structured types too to avoid ClassCastException

Modified:
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java?rev=1842148&r1=1842147&r2=1842148&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java Thu Sep 27 19:32:06
2018
@@ -514,10 +514,28 @@ public class DomXmpParser
             // no child
             String text = liElement.getTextContent();
             TypeMapping tm = xmp.getTypeMapping();
-            AbstractSimpleProperty sp = tm.instanciateSimpleProperty(descriptor.getNamespaceURI(),
-                    descriptor.getPrefix(), descriptor.getLocalPart(), text, type);
-            loadAttributes(sp, liElement);
-            return sp;
+            if (type.isSimple())
+            {
+                AbstractField af = tm.instanciateSimpleProperty(descriptor.getNamespaceURI(),
+                        descriptor.getPrefix(), descriptor.getLocalPart(), text, type);
+                loadAttributes(af, liElement);
+                return af;
+            }
+            else
+            {
+                // PDFBOX-4325: assume it is structured
+                AbstractField af;
+                try
+                {
+                    af = tm.instanciateStructuredType(type, descriptor.getLocalPart());
+                }
+                catch (BadFieldValueException ex)
+                {
+                    throw new XmpParsingException(ErrorType.InvalidType, "Parsing of structured
type failed", ex);
+                }
+                loadAttributes(af, liElement);
+                return af;
+            }
         }
     }
 



Mime
View raw message