diff options
author | Nick Burch <nick@apache.org> | 2011-09-19 11:43:09 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2011-09-19 11:43:09 +0000 |
commit | 29f7fe9eb241bc45295acc07322949c46d7817ee (patch) | |
tree | d53d0f5fdbb72444167f2c217657a9cd096549f1 /src/java/org/apache/poi/hssf | |
parent | e1deb2c1970f7e0f95eef4f9464f59c36eaa848e (diff) | |
download | poi-29f7fe9eb241bc45295acc07322949c46d7817ee.tar.gz poi-29f7fe9eb241bc45295acc07322949c46d7817ee.zip |
Fix bug #51832 - handle XLS files where the WRITEPROTECT record preceeds the FILEPASS one, rather than following as normal
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1172575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf')
-rw-r--r-- | src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java b/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java index 479169a5c2..344ad07ef3 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java @@ -57,11 +57,26 @@ public final class RecordFactoryInputStream { FilePassRecord fpr = null; if (rec instanceof BOFRecord) { _hasBOFRecord = true; + + // Fetch the next record, and see if it indicates whether + // the document is encrypted or not if (rs.hasNextRecord()) { rs.nextRecord(); rec = RecordFactory.createSingleRecord(rs); recSize += rec.getRecordSize(); outputRecs.add(rec); + + // Encrypted is normally BOF then FILEPASS + // May sometimes be BOF, WRITEPROTECT, FILEPASS + if (rec instanceof WriteProtectRecord && rs.hasNextRecord()) { + rs.nextRecord(); + rec = RecordFactory.createSingleRecord(rs); + recSize += rec.getRecordSize(); + outputRecs.add(rec); + } + + // If it's a FILEPASS, track it specifically but + // don't include it in the main stream if (rec instanceof FilePassRecord) { fpr = (FilePassRecord) rec; outputRecs.remove(outputRecs.size()-1); |