Skip to content

Commit 7add096

Browse files
committed
PDFBOX-6131: allow first char lower case in "pdfaProperty:valueType" for extension schemas + test
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930828 13f79535-47bb-0310-9956-ffa450edef68
1 parent 55d30cd commit 7add096

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@
5151
public final class PdfaExtensionHelper
5252
{
5353

54-
public static final String CLOSED_CHOICE = "closed Choice of ";
54+
private static final String CLOSED_CHOICE = "closed Choice of ";
55+
private static final String CLOSED_CHOICE_U = "Closed Choice of ";
5556

56-
public static final String OPEN_CHOICE = "open Choice of ";
57+
private static final String OPEN_CHOICE = "open Choice of ";
58+
private static final String OPEN_CHOICE_U = "Open Choice of ";
5759

5860
private PdfaExtensionHelper()
5961
{
@@ -263,19 +265,19 @@ private static PropertyType transformValueType(TypeMapping tm, String valueType)
263265
return TypeMapping.createPropertyType(Types.LangAlt, Cardinality.Simple);
264266
}
265267
// else all other cases
266-
if (valueType.startsWith(CLOSED_CHOICE))
268+
if (valueType.startsWith(CLOSED_CHOICE) || valueType.startsWith(CLOSED_CHOICE_U))
267269
{
268270
valueType = valueType.substring(CLOSED_CHOICE.length());
269271
}
270-
else if (valueType.startsWith(OPEN_CHOICE))
272+
else if (valueType.startsWith(OPEN_CHOICE) || valueType.startsWith(OPEN_CHOICE_U))
271273
{
272274
valueType = valueType.substring(OPEN_CHOICE.length());
273275
}
274276
int pos = valueType.indexOf(' ');
275277
Cardinality card = Cardinality.Simple;
276278
if (pos > 0)
277279
{
278-
String scard = valueType.substring(0, pos);
280+
String scard = valueType.substring(0, pos).toLowerCase();
279281
switch (scard)
280282
{
281283
case "seq":

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,4 +1396,17 @@ void testNoInstantiation() throws XmpParsingException
13961396
() -> xmpParser1.parse(s.getBytes(StandardCharsets.UTF_8)));
13971397
assertEquals("Failed to instantiate DateType property with value 2019-05-02T22:03:5Z in xmp:CreateDate", ex.getMessage());
13981398
}
1399+
1400+
@Test
1401+
void testPDFBox6131() throws IOException, XmpParsingException, BadFieldValueException
1402+
{
1403+
// Contains "Open Choice of Integer" instead of "open Choice of Integer"
1404+
try (InputStream is = DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/xml/PDFBOX-6131-0015675.xml"))
1405+
{
1406+
DomXmpParser xmpParser = new DomXmpParser();
1407+
XMPMetadata xmp = xmpParser.parse(is);
1408+
XMPSchema uaSchema2 = xmp.getSchema("http://www.aiim.org/pdfua/ns/id/");
1409+
assertEquals(1, uaSchema2.getIntegerPropertyValueAsSimple("part"));
1410+
}
1411+
}
13991412
}

0 commit comments

Comments
 (0)