From 622574f5f4ffd0413f2692efee5b23537b35cee9 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 3 Jan 2021 11:49:51 +0000 Subject: [PATCH] Bug 64450: Allow to parse a file where the relationship-id is an empty string Also improve exception reporting by including more information and not "hiding" the actual exception-cause in a log-statement. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885056 13f79535-47bb-0310-9956-ffa450edef68 --- .../opc/PackageRelationshipCollection.java | 8 ++++---- .../apache/poi/xssf/usermodel/TestXSSFBugs.java | 7 +++++++ test-data/spreadsheet/64450.xlsx | Bin 0 -> 9881 bytes 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 test-data/spreadsheet/64450.xlsx diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java index 9f6ebe65a6..73dec957ed 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java @@ -194,7 +194,8 @@ public final class PackageRelationshipCollection implements */ public void addRelationship(PackageRelationship relPart) { if (relPart == null || relPart.getId() == null || relPart.getId().isEmpty()) { - throw new IllegalArgumentException("invalid relationship part/id"); + throw new IllegalArgumentException("invalid relationship part/id: " + + (relPart == null ? "" : relPart.getId()) + " for relationship: " + relPart); } relationshipsByID.put(relPart.getId(), relPart); relationshipsByType.put(relPart.getRelationshipType(), relPart); @@ -216,7 +217,7 @@ public final class PackageRelationshipCollection implements */ public PackageRelationship addRelationship(URI targetUri, TargetMode targetMode, String relationshipType, String id) { - if (id == null) { + if (id == null || id.length() == 0) { // Generate a unique ID is id parameter is null. if (nextRelationshipId == -1) { nextRelationshipId = size() + 1; @@ -354,8 +355,7 @@ public final class PackageRelationshipCollection implements addRelationship(target, targetMode, type, id); } } catch (Exception e) { - logger.log(POILogger.ERROR, e); - throw new InvalidFormatException(e.getMessage()); + throw new InvalidFormatException("Failed to parse relationships", e); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index a50d1832b7..7f17019844 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3660,4 +3660,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(1, sheet.getDataValidations().size()); } } + + @Test + public void test64450() throws IOException { + try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("64450.xlsx")) { + assertNotNull(wb); + } + } } diff --git a/test-data/spreadsheet/64450.xlsx b/test-data/spreadsheet/64450.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..f96b1794126b64782c840de2ba3780c6930ff8b6 GIT binary patch literal 9881 zcmbVS1yogAwn)623uQbl*1e5IS@g2JeZ5c^i3>APm^;0v?Cu#D~(NbTKtLDX+;u|?$1{TevTvM2!RSODp2NM?J_`6~wFx-;){H53P+$Xb4+At52T^ zIxv_sOLiOFQQDf`JASN6SjKvR!1evR2b)fKIIJvMJE@}aJhduMV>}TzkQUz_rQ~OR z3(=hPh=!x!skJ50_oqT2^ZE4Ti5_fa@b_6%IKZJipE~o219&oOZUOnDuT0p3H`;w+-fF<$BwTEu8ZcmkH-L7(&1ucZd!42`}=cWm6|LDb&Px@rOcx7LN}*a_Z~wDy4us1EFbCGsnpL$+SlbnY1_e zEJRLC3M}^zqt}u;iKqAv2t!s8iY#!EBQAUPFa1Vd6|hzT%+zxO+xg*jznyIs?!(_0 zR6F~~CmLu-@2Y;k*i%cL>2e#K>0Om9Cggx-^mY_VB9%P`D5 zzjnQZeJFnpDybU!{kp2g%P0l?r>(KDO@IU8dC$1X-f*wI4I&)=ut*`nw-$lJs+&tj z?{|4N(_5;SP|M+!ut+ZbiXJ@|PVo20X?%qcJuz9oR|@%2h%iU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