From 5120b213b21a834fc0f2d989dc12a81c19bd316b Mon Sep 17 00:00:00 2001 From: Tim Allison Date: Tue, 28 Jan 2025 12:00:17 -0500 Subject: [PATCH] TIKA-4337 -- check for empty string in array index 1 (#2109) (cherry picked from commit 9a6bda5fadcc4c287926ec3361c6f398d113eab0) --- .../parser/microsoft/ooxml/xps/XPSPageContentHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xps/XPSPageContentHandler.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xps/XPSPageContentHandler.java index e6464639ff..c6114ab23d 100644 --- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xps/XPSPageContentHandler.java +++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/ooxml/xps/XPSPageContentHandler.java @@ -32,6 +32,7 @@ import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.TikaCoreProperties; import org.apache.tika.sax.XHTMLContentHandler; +import org.apache.tika.utils.StringUtils; /** @@ -247,10 +248,10 @@ private List parseIndicesString(String indicesString) throws SAXExce for (String indexString : indicesString.split(";", -1)) { // We only want to extract the advance which will be the second comma separated value String[] commaSplit = indexString.split(",", -1); - if (commaSplit.length < 2) { + if (commaSplit.length < 2 || StringUtils.isBlank(commaSplit[1])) { indices.add(new GlyphIndex(0.0f)); } else { - // Advance is measured in hundreths so divide by 100 + // Advance is measured in hundredths so divide by 100 float advance = Float.parseFloat(commaSplit[1]) / 100.0f; indices.add(new GlyphIndex(advance)); }