Skip to content

Commit e29025f

Browse files
committed
PDFBOX-5288: push "rdf:li" element; fix push/pop imbalance
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930078 13f79535-47bb-0310-9956-ffa450edef68
1 parent 830a252 commit e29025f

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,17 @@ private AbstractField parseLiElement(XMPMetadata xmp, QName descriptor, Element
548548
Element liChild = DomHelper.getUniqueElementChild(liElement);
549549
if (liChild != null)
550550
{
551-
nsFinder.push(liChild);
552-
return parseLiDescription(xmp, descriptor, liChild);
551+
try
552+
{
553+
nsFinder.push(liElement);
554+
nsFinder.push(liChild);
555+
return parseLiDescription(xmp, descriptor, liChild);
556+
}
557+
finally
558+
{
559+
nsFinder.pop();
560+
nsFinder.pop();
561+
}
553562
}
554563
else
555564
{

xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,38 @@ void testPDFBox6106() throws XmpParsingException
116116
() -> xmpParser.parse(s.getBytes(StandardCharsets.UTF_8)));
117117
Assertions.assertEquals("No type defined for {http://ns.adobe.com/pdf/1.3/}CreationDate", ex.getMessage());
118118
}
119+
120+
/**
121+
* PDFBOX-5288: check that namespace declaration within an "rdf:li" element is found.
122+
*
123+
* @throws XmpParsingException
124+
*/
125+
@Test
126+
void testPDFBox5288() throws XmpParsingException
127+
{
128+
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
129+
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?><x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Public XMP Toolkit Core 4.0 \">\n" +
130+
" \n" +
131+
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
132+
" \n" +
133+
" <rdf:Description xmlns:xmpMM=\"http://ns.adobe.com/xap/1.0/mm/\" rdf:about=\"\">\n" +
134+
" <xmpMM:DocumentID>uidd:1f0e03977b90b6365a376454ffdf34a7</xmpMM:DocumentID>\n" +
135+
" <xmpMM:History>\n" +
136+
" <rdf:Seq>\n" +
137+
" <rdf:li xmlns:stEvt=\"http://ns.adobe.com/xap/1.0/sType/ResourceEvent#\">\n" +
138+
" <rdf:Description>\n" +
139+
" <stEvt:action>created</stEvt:action>\n" +
140+
" <stEvt:parameters>iDRS PDF output engine 7</stEvt:parameters>\n" +
141+
" <stEvt:when>2022-09-12T12:00:07+02:00</stEvt:when>\n" +
142+
" </rdf:Description>\n" +
143+
" </rdf:li>\n" +
144+
" </rdf:Seq>\n" +
145+
" </xmpMM:History>\n" +
146+
" </rdf:Description>\n" +
147+
" </rdf:RDF>\n" +
148+
"</x:xmpmeta><?xpacket end=\"w\"?>";
149+
DomXmpParser xmpParser = new DomXmpParser();
150+
XMPMetadata xmp = xmpParser.parse(s.getBytes(StandardCharsets.UTF_8));
151+
Assertions.assertNotNull(xmp.getXMPMediaManagementSchema());
152+
}
119153
}

0 commit comments

Comments
 (0)