From 2bfef69f370e6500144ad937e7cbe90430c7c327 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 23 May 2014 14:07:20 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/hssf/record/NoteRecord.java | 6 +++++- src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) 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"); } /** -- 2.39.5