From edf5dc307b4fc1ce7a02b2e1e1cd7b2f8f287867 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Thu, 13 Sep 2007 19:11:10 +0000 Subject: [PATCH] fixed re-open of bug #42844. HSSFEventFactory silently skips unknown records that happen to be continued. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@575406 13f79535-47bb-0310-9956-ffa450edef68 --- .../hssf/eventusermodel/HSSFEventFactory.java | 18 +++++++----------- .../org/apache/poi/hssf/data/42844.xls | Bin 0 -> 21504 bytes .../eventusermodel/TestHSSFEventFactory.java | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/42844.xls diff --git a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java index 1cd80d535..70c989c17 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java @@ -22,15 +22,7 @@ import java.io.InputStream; import java.io.IOException; import org.apache.poi.hssf.eventusermodel.HSSFUserException; -import org.apache.poi.hssf.record.RecordFormatException; -import org.apache.poi.hssf.record.Record; -import org.apache.poi.hssf.record.RecordInputStream; -import org.apache.poi.hssf.record.RecordFactory; -import org.apache.poi.hssf.record.ContinueRecord; -import org.apache.poi.hssf.record.DrawingRecord; -import org.apache.poi.hssf.record.DrawingGroupRecord; -import org.apache.poi.hssf.record.ObjRecord; -import org.apache.poi.hssf.record.TextObjectRecord; +import org.apache.poi.hssf.record.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -151,7 +143,7 @@ public class HSSFEventFactory { in.nextRecord(); sid = in.getSid();; - + // // for some reasons we have to make the workbook to be at least 4096 bytes // but if we have such workbook we fill the end of it with zeros (many zeros) @@ -215,7 +207,11 @@ public class HSSFEventFactory rec = lastRec; } else { - throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception"); + if (rec instanceof UnknownRecord) { + ;//silently skip records we don't know about + } else { + throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception"); + } } } diff --git a/src/testcases/org/apache/poi/hssf/data/42844.xls b/src/testcases/org/apache/poi/hssf/data/42844.xls new file mode 100644 index 0000000000000000000000000000000000000000..50bb5a85b8a5e67ced80f469d2d803427b601fc3 GIT binary patch literal 21504 zcmeHPYit}>6+Y|dI)21<66e(>8^gs#GCpf261q6n>zhfT&brzH?`0 zch<2(3Pe@wx%R#1o^$Tw+;bmu@0~OIn_qWbd-lis-lTQz0jj4PYc14dqq`9AxA0B^ ze{GFX3m!onB*%S-G|=KkM>aLms|R0c{?#g?^+az{9sQ``1%yO@fS;ivwGln6%&D5^ z6Y7<`df9WQ-I$O;cCier7l^HFltxt$%tMc5rYNe;? z7{*SuQY(L@UMsVx+MaV4eVZ^ldmmOxy=ToZruH6a*hk-?U0|fNvI33?LUO*OfV-2P zqwU~I1@Meub{6!<=(}i*>rsrAA9zkchmT=qd+0EThw(-D2IE&a-}_^qbMS)Q!@Al<6+?UDX--Y{Xa- zdibZsvFJxPp&#FbKCmIZ8O2`bXa2f=^hRpgupFWWj0q0|(;0HQfeCteJ>5(n zSx-09b4KB;a?JF2Y}L|&kCIB2llcoTuv=sB^h~jbYbvlYrgJ4Fc|1ZWeIo za*KewmfZr3~S>rjuEwsCu1AJEEW=eN_HV6tVM2m?|bjO8od}lmlpH^K|dzKF9^!A zO{{yMIXrvl^WePD$aS$uUlggoB*G|pJVcX}q$zaC1sb7oiet6(!k?lO2>r6v!hs6lhM=!H>i{Po5GkI z9*kp|N@5gGh!O3fVLZ!6FlRjA`@#3nY2+9$6wCTpu0SCv5lu>y34f3h!DJv3p~*r{ zQ%W35C?z#t)^losPJ6xCVva&`Ne7j9Q$doJQwq8)_;D$bO8CZ86pkC@gbI!_H0nhj z>^vw?F6Na*ib=5`(lD0GAi;!sF(xl4(q%={a#@9vQ=ut}%SA;?=B_9d38qrP1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