From: Nick Burch Date: Fri, 23 May 2014 14:07:20 +0000 (+0000) Subject: If a NoteRecord has no author tag, it seems it can sometimes be double padded. Fixes... X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=834973efe08b0401ed6f1fd374dbcd6e2afebb1f;p=poi.git If a NoteRecord has no author tag, it seems it can sometimes be double padded. Fixes #47251 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1597098 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/record/NoteRecord.java b/src/java/org/apache/poi/hssf/record/NoteRecord.java index 86d4609606..86c239c6e5 100644 --- a/src/java/org/apache/poi/hssf/record/NoteRecord.java +++ b/src/java/org/apache/poi/hssf/record/NoteRecord.java @@ -90,7 +90,11 @@ public final class NoteRecord extends StandardRecord { } if (in.available() == 1) { field_7_padding = Byte.valueOf(in.readByte()); - } + } else if (in.available() == 2 && length == 0) { + // If there's no author, may be double padded + field_7_padding = Byte.valueOf(in.readByte()); + in.readByte(); + } } public void serialize(LittleEndianOutput out) { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index a6894a1a1b..989ea4125f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1651,8 +1651,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { openSample("47251.xls"); // Now with one that triggers on NoteRecord - // TODO Fix the bug and enable this bit of the test - //openSample("47251_1.xls"); + openSample("47251_1.xls"); } /**