XMPMetaParser { public static XMPMeta parse(Object input, ParseOptions options) throws XMPException { ParameterAsserts.assertNotNull(input); options = options != null ? options : new ParseOptions(); Document document = parseXml(input, options); boolean xmpmetaRequired = options.getRequireXMPMeta(); Object[] result = new Object[3]; result = findRootNode(document, xmpmetaRequired, result); if (result != null && result[1] == XMP_RDF) { XMPMetaImpl xmp = ParseRDF.parse((Node) result[0]); xmp.setPacketHeader((String) result[2]); if (!options.getOmitNormalization()) { return XMPNormalizer.process(xmp, options); } else { return xmp; } } else { return new XMPMetaImpl(); } } private  XMPMetaParser(); static XMPMeta parse(Object input, ParseOptions options);  }
@Test public void xxeTestFromString() throws XMPException { String metadataToParse = MessageFormatUtil.format(XMP_WITH_XXE, XXE_FILE_PATH); XMPMeta xmpMeta = XMPMetaParser.parse(metadataToParse, null); String serializedResult = XMPMetaFactory.serializeToString(xmpMeta, null); Assert.assertEquals(EXPECTED_SERIALIZED_XMP, serializedResult); }
@Test public void xxeTestFromByteBuffer() throws XMPException { String metadataToParse = MessageFormatUtil.format(XMP_WITH_XXE, XXE_FILE_PATH); XMPMeta xmpMeta = XMPMetaParser.parse(metadataToParse.getBytes(StandardCharsets.UTF_8), null); String serializedResult = XMPMetaFactory.serializeToString(xmpMeta, null); Assert.assertEquals(EXPECTED_SERIALIZED_XMP, serializedResult); }
@Test public void xxeTestFromInputStream() throws XMPException, IOException { String metadataToParse = MessageFormatUtil.format(XMP_WITH_XXE, XXE_FILE_PATH); try (InputStream inputStream = new ByteArrayInputStream(metadataToParse.getBytes(StandardCharsets.UTF_8))) { XMPMeta xmpMeta = XMPMetaParser.parse(inputStream, null); String serializedResult = XMPMetaFactory.serializeToString(xmpMeta, null); Assert.assertEquals(EXPECTED_SERIALIZED_XMP, serializedResult); } }