You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/10/21 17:34:29 UTC
svn commit: r1894453 [1/2] - in /poi/trunk:
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/
poi-ooxml/src/main/java/org/apache/poi/xssf/binary/
poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/
poi-scratchpad/src/main/java/org/apache/poi/...
Author: fanningpj
Date: Thu Oct 21 17:34:29 2021
New Revision: 1894453
URL: http://svn.apache.org/viewvc?rev=1894453&view=rev
Log:
make max record sizes configurable
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MasterTextPropAtom.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextProp9Atom.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java
poi/trunk/poi/src/main/java/org/apache/poi/ddf/UnknownEscherRecord.java
poi/trunk/poi/src/main/java/org/apache/poi/hpsf/Blob.java
poi/trunk/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java
poi/trunk/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java
poi/trunk/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/Ole10Native.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSDocument.java
poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
poi/trunk/poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
poi/trunk/poi/src/main/java/org/apache/poi/util/LZWDecompresser.java
poi/trunk/poi/src/main/java/org/apache/poi/util/StringUtil.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Thu Oct 21 17:34:29 2021
@@ -64,7 +64,7 @@ import org.openxmlformats.schemas.presen
import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
/**
- * High level representation of a ooxml slideshow.
+ * High level representation of an ooxml slideshow.
* This is the first object most users will construct whether
* they are reading or writing a slideshow. It is also the
* top level object for creating new slides/etc.
@@ -75,7 +75,8 @@ public class XMLSlideShow extends POIXML
implements SlideShow<XSLFShape, XSLFTextParagraph> {
private static final Logger LOG = LogManager.getLogger(XMLSlideShow.class);
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private CTPresentation _presentation;
private final List<XSLFSlide> _slides = new ArrayList<>();
@@ -86,6 +87,20 @@ public class XMLSlideShow extends POIXML
private XSLFNotesMaster _notesMaster;
private XSLFCommentAuthors _commentAuthors;
+ /**
+ * @param length the max record length allowed for XMLSlideShow
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for XMLSlideShow
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public XMLSlideShow() {
this(empty());
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/binary/XSSFBParser.java Thu Oct 21 17:34:29 2021
@@ -36,11 +36,26 @@ import org.apache.poi.util.LittleEndianI
public abstract class XSSFBParser {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private final LittleEndianInputStream is;
private final SparseBitSet records;
+ /**
+ * @param length the max record length allowed for XSSFBParser
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for XSSFBParser
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public XSSFBParser(InputStream is) {
this.is = new LittleEndianInputStream(is);
records = null;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkFactory.java Thu Oct 21 17:34:29 2021
@@ -43,8 +43,8 @@ import static org.apache.logging.log4j.u
public final class ChunkFactory {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
-
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/** The version of the currently open document */
private int version;
@@ -63,6 +63,20 @@ public final class ChunkFactory {
/** For logging problems we spot with the file */
private static final Logger LOG = LogManager.getLogger(ChunkFactory.class);
+ /**
+ * @param length the max record length allowed for ChunkFactory
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for ChunkFactory
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public ChunkFactory(int version) throws IOException {
this.version = version;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/CompressedStreamStore.java Thu Oct 21 17:34:29 2021
@@ -30,7 +30,8 @@ import org.apache.poi.util.IOUtils;
public final class CompressedStreamStore extends StreamStore {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 64_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 64_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/** The raw, compressed contents */
private byte[] compressedContents;
@@ -45,6 +46,20 @@ public final class CompressedStreamStore
byte[] _getBlockHeader() { return blockHeader; }
/**
+ * @param length the max record length allowed for CompressedStreamStore
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for CompressedStreamStore
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Creates a new compressed StreamStore, which will handle
* the decompression.
*/
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hdgf/streams/StreamStore.java Thu Oct 21 17:34:29 2021
@@ -26,11 +26,26 @@ import org.apache.poi.util.IOUtils;
*/
public class StreamStore { // TODO - instantiable superclass
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 10_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 10_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private byte[] contents;
/**
+ * @param length the max record length allowed for StreamStore
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for StreamStore
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Creates a new, non compressed Stream Store
*/
protected StreamStore(byte[] data, int offset, int length) {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/MAPIAttribute.java Thu Oct 21 17:34:29 2021
@@ -41,13 +41,28 @@ import org.apache.poi.util.StringUtil;
public class MAPIAttribute {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = 1_000_000;
private final MAPIProperty property;
private final int type;
private final byte[] data;
/**
+ * @param length the max record length allowed for MAPIAttribute
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for MAPIAttribute
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Constructs a single new attribute from
* the contents of the stream
*/
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hmef/attribute/TNEFAttribute.java Thu Oct 21 17:34:29 2021
@@ -35,12 +35,27 @@ import org.apache.poi.util.LittleEndian;
public class TNEFAttribute {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 20_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 20_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private final TNEFProperty property;
private final int type;
private final byte[] data;
private final int checksum;
+
+ /**
+ * @param length the max record length allowed for TNEFAttribute
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for TNEFAttribute
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
/**
* Constructs a single new attribute from the id, type,
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCTextBit.java Thu Oct 21 17:34:29 2021
@@ -26,7 +26,22 @@ import org.apache.poi.util.StringUtil;
public final class QCTextBit extends QCBit {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+ /**
+ * @param length the max record length allowed for QCTextBit
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for QCTextBit
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
public QCTextBit(String thingType, String bitType, byte[] data) {
super(thingType, bitType, data);
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java Thu Oct 21 17:34:29 2021
@@ -37,288 +37,310 @@ import org.apache.poi.util.LittleEndian;
/**
* This class provides a way to "peek" inside a powerpoint file. It
- * will print out all the types it find, and for those it know aren't
- * atoms, what they contain
- *
+ * will print out all the types it finds, and for those it knows aren't
+ * atoms, what they contain
+ * <p>
* To figure out what things are, and if they are atoms or not, used the
- * list in hslf.record.RecordTypes
- *
+ * list in hslf.record.RecordTypes
+ * <p>
* To peek inside PPDrawings, which hold Escher drawings, we use the
- * DDF package from POI (but we can fake it by using the Escher listings
- * from hslf.record.RecordTypes also)
+ * DDF package from POI (but we can fake it by using the Escher listings
+ * from hslf.record.RecordTypes also)
*/
public final class SlideShowDumper {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private byte[] docstream;
- /** Do we try to use DDF to understand the escher objects? */
- private boolean ddfEscher;
- /** Do we use our own built-in basic escher groker to understand the escher objects? */
- private boolean basicEscher;
-
- private PrintStream out;
-
- /**
- * right now this function takes one parameter: a ppt file, and outputs
- * a dump of what it contains
- */
- public static void main(String[] args) throws IOException
- {
- if(args.length == 0) {
- System.err.println("Usage: SlideShowDumper [-escher|-basicescher] <filename>");
- return;
- }
+ /**
+ * Do we try to use DDF to understand the escher objects?
+ */
+ private boolean ddfEscher;
+ /**
+ * Do we use our own built-in basic escher groker to understand the escher objects?
+ */
+ private boolean basicEscher;
+
+ private PrintStream out;
+
+ /**
+ * @param length the max record length allowed for SlideShowDumper
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for SlideShowDumper
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
+ * right now this function takes one parameter: a ppt file, and outputs
+ * a dump of what it contains
+ */
+ public static void main(String[] args) throws IOException {
+ if (args.length == 0) {
+ System.err.println("Usage: SlideShowDumper [-escher|-basicescher] <filename>");
+ return;
+ }
- String filename = args[0];
- if(args.length > 1) {
- filename = args[1];
- }
+ String filename = args[0];
+ if (args.length > 1) {
+ filename = args[1];
+ }
- try (POIFSFileSystem poifs = new POIFSFileSystem(new File(filename))) {
- SlideShowDumper foo = new SlideShowDumper(poifs, System.out);
+ try (POIFSFileSystem poifs = new POIFSFileSystem(new File(filename))) {
+ SlideShowDumper foo = new SlideShowDumper(poifs, System.out);
- if(args.length > 1) {
- if(args[0].equalsIgnoreCase("-escher")) {
- foo.setDDFEscher(true);
- } else {
- foo.setBasicEscher(true);
+ if (args.length > 1) {
+ if (args[0].equalsIgnoreCase("-escher")) {
+ foo.setDDFEscher(true);
+ } else {
+ foo.setBasicEscher(true);
+ }
}
- }
- foo.printDump();
+ foo.printDump();
+ }
}
- }
- /**
- * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the
- * document and dumps out the contents
- *
- * @param filesystem the POIFS FileSystem to read from
- * @throws IOException if there is a problem while parsing the document.
- */
- public SlideShowDumper(POIFSFileSystem filesystem, PrintStream out) throws IOException {
- // Grab the document stream
- InputStream is = filesystem.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
- docstream = IOUtils.toByteArray(is);
- is.close();
- this.out = out;
- }
-
- /**
- * Control dumping of any Escher records found - should DDF be used?
- */
- public void setDDFEscher(boolean grok) {
- ddfEscher = grok;
- basicEscher = !(grok);
- }
-
- /**
- * Control dumping of any Escher records found - should our built in
- * basic groker be used?
- */
- public void setBasicEscher(boolean grok) {
- basicEscher = grok;
- ddfEscher = !(grok);
- }
-
- public void printDump() throws IOException {
- // The format of records in a powerpoint file are:
- // <little endian 2 byte "info">
- // <little endian 2 byte "type">
- // <little endian 4 byte "length">
- // If it has a zero length, following it will be another record
- // <xx xx yy yy 00 00 00 00> <xx xx yy yy zz zz zz zz>
- // If it has a length, depending on its type it may have children or data
- // If it has children, these will follow straight away
- // <xx xx yy yy zz zz zz zz <xx xx yy yy zz zz zz zz>>
- // If it has data, this will come straigh after, and run for the length
- // <xx xx yy yy zz zz zz zz dd dd dd dd dd dd dd>
- // All lengths given exclude the 8 byte record header
- // (Data records are known as Atoms)
-
- // Document should start with:
- // 0F 00 E8 03 ## ## ## ##
- // (type 1000 = document, info 00 0f is normal, rest is document length)
- // 01 00 E9 03 28 00 00 00
- // (type 1001 = document atom, info 00 01 normal, 28 bytes long)
-
- // When parsing a document, look to see if you know about that type
- // of the current record. If you know it's a type that has children,
- // process the record's data area looking for more records
- // If you know about the type and it doesn't have children, either do
- // something with the data (eg TextRun) or skip over it
- // Otherwise, check the first byte. If you do a BINARY_AND on it with
- // 0x0f (15) and get back 0x0f, you know it has children. Otherwise
- // it doesn't
+ /**
+ * Constructs a Powerpoint dump from a POIFS Filesystem. Parses the
+ * document and dumps out the contents
+ *
+ * @param filesystem the POIFS FileSystem to read from
+ * @throws IOException if there is a problem while parsing the document.
+ */
+ public SlideShowDumper(POIFSFileSystem filesystem, PrintStream out) throws IOException {
+ // Grab the document stream
+ InputStream is = filesystem.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ docstream = IOUtils.toByteArray(is);
+ is.close();
+ this.out = out;
+ }
+
+ /**
+ * Control dumping of any Escher records found - should DDF be used?
+ */
+ public void setDDFEscher(boolean grok) {
+ ddfEscher = grok;
+ basicEscher = !(grok);
+ }
+
+ /**
+ * Control dumping of any Escher records found - should our built in
+ * basic groker be used?
+ */
+ public void setBasicEscher(boolean grok) {
+ basicEscher = grok;
+ ddfEscher = !(grok);
+ }
+
+ public void printDump() throws IOException {
+ // The format of records in a powerpoint file are:
+ // <little endian 2 byte "info">
+ // <little endian 2 byte "type">
+ // <little endian 4 byte "length">
+ // If it has a zero length, following it will be another record
+ // <xx xx yy yy 00 00 00 00> <xx xx yy yy zz zz zz zz>
+ // If it has a length, depending on its type it may have children or data
+ // If it has children, these will follow straight away
+ // <xx xx yy yy zz zz zz zz <xx xx yy yy zz zz zz zz>>
+ // If it has data, this will come straigh after, and run for the length
+ // <xx xx yy yy zz zz zz zz dd dd dd dd dd dd dd>
+ // All lengths given exclude the 8 byte record header
+ // (Data records are known as Atoms)
+
+ // Document should start with:
+ // 0F 00 E8 03 ## ## ## ##
+ // (type 1000 = document, info 00 0f is normal, rest is document length)
+ // 01 00 E9 03 28 00 00 00
+ // (type 1001 = document atom, info 00 01 normal, 28 bytes long)
+
+ // When parsing a document, look to see if you know about that type
+ // of the current record. If you know it's a type that has children,
+ // process the record's data area looking for more records
+ // If you know about the type and it doesn't have children, either do
+ // something with the data (eg TextRun) or skip over it
+ // Otherwise, check the first byte. If you do a BINARY_AND on it with
+ // 0x0f (15) and get back 0x0f, you know it has children. Otherwise
+ // it doesn't
+
+ walkTree(0, 0, docstream.length);
+ }
+
+ public void walkTree(int depth, int startPos, int maxLen) throws IOException {
+ int pos = startPos;
+ int endPos = startPos + maxLen;
+ final String ind = (depth == 0) ? "%1$s" : "%1$" + depth + "s";
+ while (pos <= endPos - 8) {
+ long type = LittleEndian.getUShort(docstream, pos + 2);
+ long len = LittleEndian.getUInt(docstream, pos + 4);
+ byte opt = docstream[pos];
+
+ String fmt = ind + "At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
+ out.println(String.format(Locale.ROOT, fmt, "", pos, type, len));
+
+ // See if we know about the type of it
+ String recordName = RecordTypes.forTypeID((short) type).name();
+
+ // Jump over header, and think about going on more
+ pos += 8;
+ out.println(String.format(Locale.ROOT, ind + "That's a %2$s", "", recordName));
+
+ // Now check if it's a container or not
+ int container = opt & 0x0f;
+
+ // BinaryTagData seems to contain records, but it
+ // isn't tagged as doing so. Try stepping in anyway
+ if (type == 5003L && opt == 0L) {
+ container = 0x0f;
+ }
- walkTree(0,0,docstream.length);
-}
+ out.println();
+ if (type != 0L && container == 0x0f) {
+ if (type == 1035L || type == 1036L) {
+ // Special Handling of 1035=PPDrawingGroup and 1036=PPDrawing
+ if (ddfEscher) {
+ // Seems to be:
+ walkEscherDDF((depth + 3), pos + 8, (int) len - 8);
+ } else if (basicEscher) {
+ walkEscherBasic((depth + 3), pos + 8, (int) len - 8);
+ }
+ } else {
+ // General container record handling code
+ walkTree((depth + 2), pos, (int) len);
+ }
+ }
-public void walkTree(int depth, int startPos, int maxLen) throws IOException {
- int pos = startPos;
- int endPos = startPos + maxLen;
- final String ind = (depth == 0) ? "%1$s" : "%1$"+depth+"s";
- while(pos <= endPos - 8) {
- long type = LittleEndian.getUShort(docstream,pos+2);
- long len = LittleEndian.getUInt(docstream,pos+4);
- byte opt = docstream[pos];
-
- String fmt = ind+"At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
- out.println(String.format(Locale.ROOT, fmt, "", pos, type, len));
-
- // See if we know about the type of it
- String recordName = RecordTypes.forTypeID((short)type).name();
-
- // Jump over header, and think about going on more
- pos += 8;
- out.println(String.format(Locale.ROOT, ind+"That's a %2$s", "", recordName));
-
- // Now check if it's a container or not
- int container = opt & 0x0f;
-
- // BinaryTagData seems to contain records, but it
- // isn't tagged as doing so. Try stepping in anyway
- if(type == 5003L && opt == 0L) {
- container = 0x0f;
+ pos += (int) len;
}
+ }
- out.println();
- if (type != 0L && container == 0x0f) {
- if (type == 1035L || type == 1036L) {
- // Special Handling of 1035=PPDrawingGroup and 1036=PPDrawing
- if(ddfEscher) {
- // Seems to be:
- walkEscherDDF((depth+3),pos+8,(int)len-8);
- } else if(basicEscher) {
- walkEscherBasic((depth+3),pos+8,(int)len-8);
- }
- } else {
- // General container record handling code
- walkTree((depth+2),pos,(int)len);
- }
+ /**
+ * Use the DDF code to walk the Escher records
+ */
+ public void walkEscherDDF(int indent, int pos, int len) {
+ if (len < 8) {
+ return;
}
- pos += (int)len;
- }
- }
+ final String ind = (indent == 0) ? "%1$s" : "%1$" + indent + "s";
- /**
- * Use the DDF code to walk the Escher records
- */
- public void walkEscherDDF(int indent, int pos, int len) {
- if(len < 8) { return; }
+ byte[] contents = IOUtils.safelyClone(docstream, pos, len, MAX_RECORD_LENGTH);
+ DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
+ EscherRecord record = erf.createRecord(contents, 0);
- final String ind = (indent == 0) ? "%1$s" : "%1$"+indent+"s";
+ // For now, try filling in the fields
+ record.fillFields(contents, 0, erf);
- byte[] contents = IOUtils.safelyClone(docstream, pos, len, MAX_RECORD_LENGTH);
- DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
- EscherRecord record = erf.createRecord(contents,0);
+ long atomType = LittleEndian.getUShort(contents, 2);
+ // This lacks the 8 byte header size
+ long atomLen = LittleEndian.getUShort(contents, 4);
+ // This (should) include the 8 byte header size
+ int recordLen = record.getRecordSize();
- // For now, try filling in the fields
- record.fillFields(contents,0,erf);
+ String fmt = ind + "At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x) (%5$d) - record claims %6$d";
+ out.println(String.format(Locale.ROOT, fmt, "", pos, atomType, atomLen, atomLen + 8, recordLen));
- long atomType = LittleEndian.getUShort(contents,2);
- // This lacks the 8 byte header size
- long atomLen = LittleEndian.getUShort(contents,4);
- // This (should) include the 8 byte header size
- int recordLen = record.getRecordSize();
- String fmt = ind+"At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x) (%5$d) - record claims %6$d";
- out.println(String.format(Locale.ROOT, fmt, "", pos, atomType, atomLen, atomLen+8, recordLen));
+ // Check for corrupt / lying ones
+ if (recordLen != 8 && (recordLen != (atomLen + 8))) {
+ out.println(String.format(Locale.ROOT, ind + "** Atom length of $2d ($3d) doesn't match record length of %4d", "", atomLen, atomLen + 8, recordLen));
+ }
+ // Print the record's details
+ String recordStr = record.toString().replace("\n", String.format(Locale.ROOT, "\n" + ind, ""));
+ out.println(String.format(Locale.ROOT, ind + "%2$s", "", recordStr));
- // Check for corrupt / lying ones
- if(recordLen != 8 && (recordLen != (atomLen+8))) {
- out.println(String.format(Locale.ROOT, ind+"** Atom length of $2d ($3d) doesn't match record length of %4d", "", atomLen, atomLen+8, recordLen));
- }
+ if (record instanceof EscherContainerRecord) {
+ walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
+ }
- // Print the record's details
- String recordStr = record.toString().replace("\n", String.format(Locale.ROOT, "\n"+ind, ""));
- out.println(String.format(Locale.ROOT, ind+"%2$s", "", recordStr));
+ // Handle records that seem to lie
+ if (atomType == 61451L) {
+ // Normally claims a size of 8
+ recordLen = (int) atomLen + 8;
+ }
+ if (atomType == 61453L) {
+ // Returns EscherContainerRecord, but really msofbtClientTextbox
+ recordLen = (int) atomLen + 8;
+ record.fillFields(contents, 0, erf);
+ if (!(record instanceof EscherTextboxRecord)) {
+ out.println(String.format(Locale.ROOT, ind + "%2$s", "", "** Really a msofbtClientTextbox !"));
+ }
+ }
- if(record instanceof EscherContainerRecord) {
- walkEscherDDF((indent+3), pos + 8, (int)atomLen );
- }
+ // Decide on what to do, based on how the lengths match up
+ if (recordLen == 8 && atomLen > 8) {
+ // Assume it has children, rather than being corrupted
+ walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
+
+ // Wind on our length + our header
+ pos += atomLen;
+ pos += 8;
+ len -= atomLen;
+ len -= 8;
+ } else {
+ // No children, wind on our real length
+ pos += atomLen;
+ pos += 8;
+ len -= atomLen;
+ len -= 8;
+ }
- // Handle records that seem to lie
- if(atomType == 61451L) {
- // Normally claims a size of 8
- recordLen = (int)atomLen + 8;
- }
- if(atomType == 61453L) {
- // Returns EscherContainerRecord, but really msofbtClientTextbox
- recordLen = (int)atomLen + 8;
- record.fillFields( contents, 0, erf );
- if(! (record instanceof EscherTextboxRecord)) {
- out.println(String.format(Locale.ROOT, ind+"%2$s", "", "** Really a msofbtClientTextbox !"));
+ // Move on to the next one, if we're not at the end yet
+ if (len >= 8) {
+ walkEscherDDF(indent, pos, len);
}
}
- // Decide on what to do, based on how the lengths match up
- if(recordLen == 8 && atomLen > 8 ) {
- // Assume it has children, rather than being corrupted
- walkEscherDDF((indent+3), pos + 8, (int)atomLen );
-
- // Wind on our length + our header
- pos += atomLen;
- pos += 8;
- len -= atomLen;
- len -= 8;
- } else {
- // No children, wind on our real length
- pos += atomLen;
- pos += 8;
- len -= atomLen;
- len -= 8;
- }
+ /**
+ * Use the basic record format groking code to walk the Escher records
+ */
+ public void walkEscherBasic(int indent, int pos, int len) throws IOException {
+ if (len < 8) {
+ return;
+ }
- // Move on to the next one, if we're not at the end yet
- if(len >= 8) {
- walkEscherDDF(indent, pos, len );
- }
- }
+ final String ind = (indent == 0) ? "%1$s" : "%1$" + indent + "s";
- /**
- * Use the basic record format groking code to walk the Escher records
- */
- public void walkEscherBasic(int indent, int pos, int len) throws IOException {
- if(len < 8) { return; }
-
- final String ind = (indent == 0) ? "%1$s" : "%1$"+indent+"s";
-
- long type = LittleEndian.getUShort(docstream,pos+2);
- long atomlen = LittleEndian.getUInt(docstream,pos+4);
-
- String fmt = ind+"At position %2$d ($2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
- out.println(String.format(Locale.ROOT, fmt, "", pos, type, atomlen));
-
- String typeName = RecordTypes.forTypeID((short)type).name();
- out.println(String.format(Locale.ROOT, ind+"%2$s", "That's an Escher Record: ", typeName));
-
- // Record specific dumps
- if(type == 61453L) {
- // Text Box. Print out first 8 bytes of data, then 8 4 later
- HexDump.dump(docstream, 0, out, pos+8, 8);
- HexDump.dump(docstream, 0, out, pos+20, 8);
- out.println();
- }
+ long type = LittleEndian.getUShort(docstream, pos + 2);
+ long atomlen = LittleEndian.getUInt(docstream, pos + 4);
+ String fmt = ind + "At position %2$d ($2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
+ out.println(String.format(Locale.ROOT, fmt, "", pos, type, atomlen));
- // Blank line before next entry
- out.println();
+ String typeName = RecordTypes.forTypeID((short) type).name();
+ out.println(String.format(Locale.ROOT, ind + "%2$s", "That's an Escher Record: ", typeName));
+
+ // Record specific dumps
+ if (type == 61453L) {
+ // Text Box. Print out first 8 bytes of data, then 8 4 later
+ HexDump.dump(docstream, 0, out, pos + 8, 8);
+ HexDump.dump(docstream, 0, out, pos + 20, 8);
+ out.println();
+ }
- // Look in children if we are a container
- if(type == 61443L || type == 61444L) {
- walkEscherBasic((indent+3), pos+8, (int)atomlen);
- }
- // Keep going if not yet at end
- if(atomlen < len) {
- int atomleni = (int)atomlen;
- walkEscherBasic(indent, pos+atomleni+8, len-atomleni-8);
+ // Blank line before next entry
+ out.println();
+
+ // Look in children if we are a container
+ if (type == 61443L || type == 61444L) {
+ walkEscherBasic((indent + 3), pos + 8, (int) atomlen);
+ }
+
+ // Keep going if not yet at end
+ if (atomlen < len) {
+ int atomleni = (int) atomlen;
+ walkEscherBasic(indent, pos + atomleni + 8, len - atomleni - 8);
+ }
}
- }
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CString.java Thu Oct 21 17:34:29 2021
@@ -31,13 +31,14 @@ import org.apache.poi.util.StringUtil;
/**
* A CString (type 4026). Holds a unicode string, and the first two bytes
* of the record header normally encode the count. Typically attached to
- * some complex sequence of records, eg Commetns.
+ * some complex sequence of records, eg Comments.
*/
public final class CString extends RecordAtom {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = 1_000_000;
private byte[] _header;
@@ -49,6 +50,20 @@ public final class CString extends Recor
return StringUtil.getFromUnicodeLE(_text);
}
+ /**
+ * @param length the max record length allowed for CString
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for CString
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
/** Updates the text in the Atom. */
public void setText(String text) {
// Convert to little endian unicode
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjListAtom.java Thu Oct 21 17:34:29 2021
@@ -36,7 +36,8 @@ public class ExObjListAtom extends Recor
{
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
* Record header.
@@ -49,6 +50,20 @@ public class ExObjListAtom extends Recor
private byte[] _data;
/**
+ * @param length the max record length allowed for MasterTextPropAtom
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for MasterTextPropAtom
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Constructs a brand new link related atom record.
*/
protected ExObjListAtom() {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java Thu Oct 21 17:34:29 2021
@@ -51,14 +51,14 @@ public class FontEmbeddedData extends Re
private FontHeader fontHeader;
/**
- * @param length the max length allowed for FontEmbeddedData
+ * @param length the max record length allowed for FontEmbeddedData
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for FontEmbeddedData
+ * @return the max record length allowed for FontEmbeddedData
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MasterTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MasterTextPropAtom.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MasterTextPropAtom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/MasterTextPropAtom.java Thu Oct 21 17:34:29 2021
@@ -38,7 +38,8 @@ import org.apache.poi.util.LittleEndian;
public final class MasterTextPropAtom extends RecordAtom {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
* Record header.
@@ -54,6 +55,20 @@ public final class MasterTextPropAtom ex
private List<IndentProp> indents;
/**
+ * @param length the max record length allowed for MasterTextPropAtom
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for MasterTextPropAtom
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Constructs a new empty master text prop atom.
*/
public MasterTextPropAtom() {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextProp9Atom.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextProp9Atom.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextProp9Atom.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/StyleTextProp9Atom.java Thu Oct 21 17:34:29 2021
@@ -36,7 +36,8 @@ import org.apache.poi.util.LittleEndian;
public final class StyleTextProp9Atom extends RecordAtom {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private final TextPFException9[] autoNumberSchemes;
/** Record header. */
@@ -48,6 +49,20 @@ public final class StyleTextProp9Atom ex
private int length;
/**
+ * @param length the max record length allowed for StyleTextProp9Atom
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for StyleTextProp9Atom
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Constructs the link related atom record from its
* source data.
*
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Thu Oct 21 17:34:29 2021
@@ -85,7 +85,8 @@ public final class HSLFSlideShow extends
private static final Logger LOG = LogManager.getLogger(HSLFSlideShow.class);
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 10_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 10_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
enum LoadSavePhase {
INIT, LOADED
@@ -112,6 +113,19 @@ public final class HSLFSlideShow extends
private final List<HSLFNotes> _notes = new ArrayList<>();
private FontCollection _fonts;
+ /**
+ * @param length the max record length allowed for HSLFSlideShow
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for HSLFSlideShow
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
/**
* Constructs a Powerpoint document from the underlying
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java Thu Oct 21 17:34:29 2021
@@ -60,7 +60,8 @@ public abstract class PropertiesChunk ex
public static final String NAME = "__properties_version1.0";
// arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
// standard prefix, defined in the spec
public static final String VARIABLE_LENGTH_PROPERTY_PREFIX = "__substg1.0_";
@@ -85,6 +86,20 @@ public abstract class PropertiesChunk ex
private final ChunkGroup parentGroup;
/**
+ * @param length the max record length allowed for PropertiesChunk
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for PropertiesChunk
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Creates a Properties Chunk.
*/
protected PropertiesChunk(ChunkGroup parentGroup) {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java Thu Oct 21 17:34:29 2021
@@ -29,11 +29,26 @@ public final class DocumentProperties ex
{
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private byte[] _preserved;
/**
+ * @param length the max record length allowed for DocumentProperties
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for DocumentProperties
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* @deprecated Use {@link #DocumentProperties(byte[],int,int)} instead
*/
public DocumentProperties( byte[] tableStream, int offset )
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java Thu Oct 21 17:34:29 2021
@@ -32,175 +32,172 @@ import org.apache.poi.util.LittleEndianC
* that stores info about the whole structure and the fonts
*/
@Internal
-public final class Ffn
-{
+public final class Ffn {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ //arbitrarily selected; may need to increase
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
- private int _cbFfnM1;//total length of FFN - 1.
- private byte _info;
+ private int _cbFfnM1;//total length of FFN - 1.
+ private byte _info;
private static BitField _prq = BitFieldFactory.getInstance(0x0003);// pitch request
private static BitField _fTrueType = BitFieldFactory.getInstance(0x0004);// when 1, font is a TrueType font
private static BitField _ff = BitFieldFactory.getInstance(0x0070);
- private short _wWeight;// base weight of font
- private byte _chs;// character set identifier
- private byte _ixchSzAlt; // index into ffn.szFfn to the name of
- // the alternate font
- private byte [] _panose = new byte[10];//????
- private byte [] _fontSig = new byte[24];//????
-
- // zero terminated string that records name of font, cuurently not
- // supporting Extended chars
- private char [] _xszFfn;
-
- // extra facilitator members
- private int _xszFfnLength;
-
- public Ffn(byte[] buf, int offset)
- {
- int offsetTmp = offset;
-
- _cbFfnM1 = LittleEndian.getUByte(buf,offset);
- offset += LittleEndianConsts.BYTE_SIZE;
- _info = buf[offset];
- offset += LittleEndianConsts.BYTE_SIZE;
- _wWeight = LittleEndian.getShort(buf, offset);
- offset += LittleEndianConsts.SHORT_SIZE;
- _chs = buf[offset];
- offset += LittleEndianConsts.BYTE_SIZE;
- _ixchSzAlt = buf[offset];
- offset += LittleEndianConsts.BYTE_SIZE;
-
- // read panose and fs so we can write them back out.
- System.arraycopy(buf, offset, _panose, 0, _panose.length);
- offset += _panose.length;
- System.arraycopy(buf, offset, _fontSig, 0, _fontSig.length);
- offset += _fontSig.length;
-
- offsetTmp = offset - offsetTmp;
- _xszFfnLength = (this.getSize() - offsetTmp)/2;
- _xszFfn = new char[_xszFfnLength];
-
- for(int i = 0; i < _xszFfnLength; i++)
- {
- _xszFfn[i] = (char)LittleEndian.getShort(buf, offset);
- offset += LittleEndianConsts.SHORT_SIZE;
- }
-
-
- }
-
- public int get_cbFfnM1()
- {
- return _cbFfnM1;
- }
-
- public short getWeight()
- {
- return _wWeight;
- }
-
- public byte getChs()
- {
- return _chs;
- }
-
- public byte [] getPanose()
- {
- return _panose;
- }
-
- public byte [] getFontSig()
- {
- return _fontSig;
- }
-
- public int getSize()
- {
- return (_cbFfnM1 + 1);
- }
-
- public String getMainFontName()
- {
- int index = 0;
- for (;index < _xszFfnLength; index++)
- {
- if (_xszFfn[index] == '\0')
- {
- break;
- }
- }
- return new String(_xszFfn, 0, index);
- }
-
- public String getAltFontName()
- {
- int index = _ixchSzAlt;
- for (;index < _xszFfnLength; index++)
- {
- if (_xszFfn[index] == '\0')
- {
- break;
- }
- }
- return new String(_xszFfn, _ixchSzAlt, index);
-
- }
-
- public void set_cbFfnM1(int _cbFfnM1)
- {
- this._cbFfnM1 = _cbFfnM1;
- }
-
- // changed protected to public
- public byte[] toByteArray()
- {
- int offset = 0;
- byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH);
-
- buf[offset] = (byte)_cbFfnM1;
- offset += LittleEndianConsts.BYTE_SIZE;
- buf[offset] = _info;
- offset += LittleEndianConsts.BYTE_SIZE;
- LittleEndian.putShort(buf, offset, _wWeight);
- offset += LittleEndianConsts.SHORT_SIZE;
- buf[offset] = _chs;
- offset += LittleEndianConsts.BYTE_SIZE;
- buf[offset] = _ixchSzAlt;
- offset += LittleEndianConsts.BYTE_SIZE;
-
- System.arraycopy(_panose,0,buf, offset,_panose.length);
- offset += _panose.length;
- System.arraycopy(_fontSig,0,buf, offset, _fontSig.length);
- offset += _fontSig.length;
-
- for(int i = 0; i < _xszFfn.length; i++)
- {
- LittleEndian.putShort(buf, offset, (short)_xszFfn[i]);
- offset += LittleEndianConsts.SHORT_SIZE;
- }
-
- return buf;
-
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof Ffn)) return false;
- Ffn o = (Ffn)other;
-
- return (
- o._cbFfnM1 == this._cbFfnM1
- && o._info == this._info
- && o._wWeight == _wWeight
- && o._chs == _chs
- && o._ixchSzAlt == _ixchSzAlt
- && Arrays.equals(o._panose,_panose)
- && Arrays.equals(o._fontSig,_fontSig)
- && Arrays.equals(o._xszFfn,_xszFfn)
- );
- }
+ private short _wWeight;// base weight of font
+ private byte _chs;// character set identifier
+ private byte _ixchSzAlt; // index into ffn.szFfn to the name of
+ // the alternate font
+ private byte[] _panose = new byte[10];//????
+ private byte[] _fontSig = new byte[24];//????
+
+ // zero terminated string that records name of font, cuurently not
+ // supporting Extended chars
+ private char[] _xszFfn;
+
+ // extra facilitator members
+ private int _xszFfnLength;
+
+ /**
+ * @param length the max record length allowed for Ffn
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for Ffn
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ public Ffn(byte[] buf, int offset) {
+ int offsetTmp = offset;
+
+ _cbFfnM1 = LittleEndian.getUByte(buf, offset);
+ offset += LittleEndianConsts.BYTE_SIZE;
+ _info = buf[offset];
+ offset += LittleEndianConsts.BYTE_SIZE;
+ _wWeight = LittleEndian.getShort(buf, offset);
+ offset += LittleEndianConsts.SHORT_SIZE;
+ _chs = buf[offset];
+ offset += LittleEndianConsts.BYTE_SIZE;
+ _ixchSzAlt = buf[offset];
+ offset += LittleEndianConsts.BYTE_SIZE;
+
+ // read panose and fs so we can write them back out.
+ System.arraycopy(buf, offset, _panose, 0, _panose.length);
+ offset += _panose.length;
+ System.arraycopy(buf, offset, _fontSig, 0, _fontSig.length);
+ offset += _fontSig.length;
+
+ offsetTmp = offset - offsetTmp;
+ _xszFfnLength = (this.getSize() - offsetTmp) / 2;
+ _xszFfn = new char[_xszFfnLength];
+
+ for (int i = 0; i < _xszFfnLength; i++) {
+ _xszFfn[i] = (char) LittleEndian.getShort(buf, offset);
+ offset += LittleEndianConsts.SHORT_SIZE;
+ }
+
+
+ }
+
+ public int get_cbFfnM1() {
+ return _cbFfnM1;
+ }
+
+ public short getWeight() {
+ return _wWeight;
+ }
+
+ public byte getChs() {
+ return _chs;
+ }
+
+ public byte[] getPanose() {
+ return _panose;
+ }
+
+ public byte[] getFontSig() {
+ return _fontSig;
+ }
+
+ public int getSize() {
+ return (_cbFfnM1 + 1);
+ }
+
+ public String getMainFontName() {
+ int index = 0;
+ for (; index < _xszFfnLength; index++) {
+ if (_xszFfn[index] == '\0') {
+ break;
+ }
+ }
+ return new String(_xszFfn, 0, index);
+ }
+
+ public String getAltFontName() {
+ int index = _ixchSzAlt;
+ for (; index < _xszFfnLength; index++) {
+ if (_xszFfn[index] == '\0') {
+ break;
+ }
+ }
+ return new String(_xszFfn, _ixchSzAlt, index);
+
+ }
+
+ public void set_cbFfnM1(int _cbFfnM1) {
+ this._cbFfnM1 = _cbFfnM1;
+ }
+
+ // changed protected to public
+ public byte[] toByteArray() {
+ int offset = 0;
+ byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH);
+
+ buf[offset] = (byte) _cbFfnM1;
+ offset += LittleEndianConsts.BYTE_SIZE;
+ buf[offset] = _info;
+ offset += LittleEndianConsts.BYTE_SIZE;
+ LittleEndian.putShort(buf, offset, _wWeight);
+ offset += LittleEndianConsts.SHORT_SIZE;
+ buf[offset] = _chs;
+ offset += LittleEndianConsts.BYTE_SIZE;
+ buf[offset] = _ixchSzAlt;
+ offset += LittleEndianConsts.BYTE_SIZE;
+
+ System.arraycopy(_panose, 0, buf, offset, _panose.length);
+ offset += _panose.length;
+ System.arraycopy(_fontSig, 0, buf, offset, _fontSig.length);
+ offset += _fontSig.length;
+
+ for (int i = 0; i < _xszFfn.length; i++) {
+ LittleEndian.putShort(buf, offset, (short) _xszFfn[i]);
+ offset += LittleEndianConsts.SHORT_SIZE;
+ }
+
+ return buf;
+
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof Ffn)) return false;
+ Ffn o = (Ffn) other;
+
+ return (
+ o._cbFfnM1 == this._cbFfnM1
+ && o._info == this._info
+ && o._wWeight == _wWeight
+ && o._chs == _chs
+ && o._ixchSzAlt == _ixchSzAlt
+ && Arrays.equals(o._panose, _panose)
+ && Arrays.equals(o._fontSig, _fontSig)
+ && Arrays.equals(o._xszFfn, _xszFfn)
+ );
+ }
@Override
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java Thu Oct 21 17:34:29 2021
@@ -28,9 +28,6 @@ import org.apache.poi.util.LittleEndianC
@Internal
public final class SprmBuffer implements Duplicatable {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
byte[] _buf;
boolean _istd;
int _offset;
@@ -56,7 +53,7 @@ public final class SprmBuffer implements
}
public SprmBuffer(int sprmsStartOffset) {
- _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, MAX_RECORD_LENGTH);
+ _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, SprmUtils.MAX_RECORD_LENGTH);
_offset = sprmsStartOffset;
_sprmsStartOffset = sprmsStartOffset;
}
@@ -118,7 +115,7 @@ public final class SprmBuffer implements
// commented - buffer shall not contain any additional bytes --
// sergey
// byte[] newBuf = new byte[_offset + addition + 6];
- IOUtils.safelyAllocateCheck(_offset + (long)addition, MAX_RECORD_LENGTH);
+ IOUtils.safelyAllocateCheck(_offset + (long)addition, SprmUtils.MAX_RECORD_LENGTH);
_buf = Arrays.copyOf(_buf, _offset + addition);
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java Thu Oct 21 17:34:29 2021
@@ -30,14 +30,14 @@ public final class SprmUtils {
static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
- * @param length the max length allowed for SPRM data
+ * @param length the max record length allowed for SPRM data
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for SPRM data
+ * @return the max record length allowed for SPRM data
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java Thu Oct 21 17:34:29 2021
@@ -37,7 +37,8 @@ import org.apache.poi.util.Removal;
public final class EscherArrayProperty extends EscherComplexProperty implements Iterable<byte[]> {
// arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
/**
* The size of the header that goes at the start of the array, before the data
@@ -55,6 +56,20 @@ public final class EscherArrayProperty e
private final boolean emptyComplexPart;
/**
+ * @param length the max record length allowed for EscherArrayProperty
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for EscherArrayProperty
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* Create an instance of an escher array property.
* This constructor can be used to create emptyComplexParts with a complexSize = 0.
* Preferably use {@link #EscherArrayProperty(EscherPropertyTypes, boolean, int)} with {@link #setComplexData(byte[])}.
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java Thu Oct 21 17:34:29 2021
@@ -57,14 +57,14 @@ public final class EscherBSERecord exten
private byte[] _remainingData = new byte[0];
/**
- * @param length the max length allowed for EscherBSERecord
+ * @param length the max record length allowed for EscherBSERecord
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherBSERecord
+ * @return the max record length allowed for EscherBSERecord
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java Thu Oct 21 17:34:29 2021
@@ -38,14 +38,14 @@ public class EscherBlipRecord extends Es
private byte[] field_pictureData;
/**
- * @param length the max length allowed for EscherBlipRecord
+ * @param length the max record length allowed for EscherBlipRecord
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherBlipRecord
+ * @return the max record length allowed for EscherBlipRecord
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java Thu Oct 21 17:34:29 2021
@@ -62,14 +62,14 @@ public class EscherClientAnchorRecord ex
private boolean shortRecord;
/**
- * @param length the max length allowed for EscherClientAnchorRecord
+ * @param length the max record length allowed for EscherClientAnchorRecord
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherClientAnchorRecord
+ * @return the max record length allowed for EscherClientAnchorRecord
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java Thu Oct 21 17:34:29 2021
@@ -41,14 +41,14 @@ public class EscherClientDataRecord exte
private byte[] remainingData;
/**
- * @param length the max length allowed for EscherClientDataRecord
+ * @param length the max record length allowed for EscherClientDataRecord
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherClientDataRecord
+ * @return the max record length allowed for EscherClientDataRecord
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java Thu Oct 21 17:34:29 2021
@@ -79,14 +79,14 @@ public final class EscherMetafileBlip ex
private byte[] remainingData;
/**
- * @param length the max length allowed for EscherMetafileBlip
+ * @param length the max record length allowed for EscherMetafileBlip
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherMetafileBlip
+ * @return the max record length allowed for EscherMetafileBlip
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java Thu Oct 21 17:34:29 2021
@@ -45,14 +45,14 @@ public final class EscherTextboxRecord e
private byte[] thedata = NO_BYTES;
/**
- * @param length the max length allowed for EscherTextboxRecord
+ * @param length the max record length allowed for EscherTextboxRecord
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for EscherTextboxRecord
+ * @return the max record length allowed for EscherTextboxRecord
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ddf/UnknownEscherRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ddf/UnknownEscherRecord.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ddf/UnknownEscherRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ddf/UnknownEscherRecord.java Thu Oct 21 17:34:29 2021
@@ -34,7 +34,8 @@ import org.apache.poi.util.LittleEndian;
public final class UnknownEscherRecord extends EscherRecord {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private static final byte[] NO_BYTES = new byte[0];
@@ -42,6 +43,20 @@ public final class UnknownEscherRecord e
private byte[] thedata = NO_BYTES;
private final List<EscherRecord> _childRecords = new ArrayList<>();
+ /**
+ * @param length the max record length allowed for UnknownEscherRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for UnknownEscherRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public UnknownEscherRecord() {}
public UnknownEscherRecord(UnknownEscherRecord other) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hpsf/Blob.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hpsf/Blob.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hpsf/Blob.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hpsf/Blob.java Thu Oct 21 17:34:29 2021
@@ -30,14 +30,14 @@ public class Blob {
private byte[] _value;
/**
- * @param length the max length allowed for Blob
+ * @param length the max record length allowed for Blob
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for Blob
+ * @return the max record length allowed for Blob
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java Thu Oct 21 17:34:29 2021
@@ -38,14 +38,14 @@ public class ClipboardData {
private byte[] _value;
/**
- * @param length the max length allowed for ClipboardData
+ * @param length the max record length allowed for ClipboardData
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for ClipboardData
+ * @return the max record length allowed for ClipboardData
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java Thu Oct 21 17:34:29 2021
@@ -42,14 +42,14 @@ public class CodePageString {
private byte[] _value;
/**
- * @param length the max length allowed for CodePageString
+ * @param length the max record length allowed for CodePageString
*/
public static void setMaxRecordLength(int length) {
MAX_RECORD_LENGTH = length;
}
/**
- * @return the max length allowed for CodePageString
+ * @return the max record length allowed for CodePageString
*/
public static int getMaxRecordLength() {
return MAX_RECORD_LENGTH;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java Thu Oct 21 17:34:29 2021
@@ -63,8 +63,8 @@ public class OldExcelExtractor implement
private static final int FILE_PASS_RECORD_SID = 0x2f;
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
-
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private RecordInputStream ris;
@@ -74,6 +74,20 @@ public class OldExcelExtractor implement
private int biffVersion;
private int fileType;
+ /**
+ * @param length the max record length allowed for OldExcelExtractor
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for OldExcelExtractor
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public OldExcelExtractor(InputStream input) throws IOException {
open(input);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java Thu Oct 21 17:34:29 2021
@@ -38,12 +38,27 @@ public final class Biff8DecryptingStream
public static final int RC4_REKEYING_INTERVAL = 1024;
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private final ChunkedCipherInputStream ccis;
private final byte[] buffer = new byte[LittleEndianConsts.LONG_SIZE];
private boolean shouldSkipEncryptionOnCurrentRecord;
+ /**
+ * @param length the max record length allowed for Biff8DecryptingStream
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for Biff8DecryptingStream
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public Biff8DecryptingStream(InputStream in, int initialOffset, EncryptionInfo info) throws RecordFormatException {
try {
byte[] initialBuf = IOUtils.safelyAllocate(initialOffset, MAX_RECORD_LENGTH);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Thu Oct 21 17:34:29 2021
@@ -138,8 +138,10 @@ import org.apache.poi.util.Removal;
public final class HSSFWorkbook extends POIDocument implements Workbook {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
- private static final int MAX_IMAGE_LENGTH = 50_000_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+ private static final int DEFAULT_MAX_IMAGE_LENGTH = 50_000_000;
+ private static int MAX_IMAGE_LENGTH = DEFAULT_MAX_IMAGE_LENGTH;
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
@@ -219,6 +221,34 @@ public final class HSSFWorkbook extends
}
/**
+ * @param length the max record length allowed for HSSFWorkbook
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for HSSFWorkbook
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
+ * @param length the max image length allowed for HSSFWorkbook
+ */
+ public static void setMaxImageLength(int length) {
+ MAX_IMAGE_LENGTH = length;
+ }
+
+ /**
+ * @return the max image length allowed for HSSFWorkbook
+ */
+ public static int getMaxImageLength() {
+ return MAX_IMAGE_LENGTH;
+ }
+
+ /**
* Creates new HSSFWorkbook from scratch (start here!)
*/
public HSSFWorkbook() {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java Thu Oct 21 17:34:29 2021
@@ -31,10 +31,6 @@ import org.apache.poi.util.LittleEndianI
@Internal
public abstract class ChunkedCipherInputStream extends LittleEndianInputStream {
- //arbitrarily selected; may need to increase
- private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
- private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
-
private final int chunkSize;
private final int chunkBits;
@@ -46,20 +42,6 @@ public abstract class ChunkedCipherInput
private long pos;
private boolean chunkIsValid;
- /**
- * @param length the max length allowed for ChunkedCipherInputStream
- */
- public static void setMaxRecordLength(int length) {
- MAX_RECORD_LENGTH = length;
- }
-
- /**
- * @return the max length allowed for ChunkedCipherInputStream
- */
- public static int getMaxRecordLength() {
- return MAX_RECORD_LENGTH;
- }
-
public ChunkedCipherInputStream(InputStream stream, long size, int chunkSize)
throws GeneralSecurityException {
this(stream, size, chunkSize, 0);
@@ -72,8 +54,8 @@ public abstract class ChunkedCipherInput
this.pos = initialPos;
this.chunkSize = chunkSize;
int cs = chunkSize == -1 ? 4096 : chunkSize;
- this.chunk = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
- this.plain = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
+ this.chunk = IOUtils.safelyAllocate(cs, CryptoFunctions.MAX_RECORD_LENGTH);
+ this.plain = IOUtils.safelyAllocate(cs, CryptoFunctions.MAX_RECORD_LENGTH);
this.chunkBits = Integer.bitCount(chunk.length-1);
this.lastIndex = (int)(pos >> chunkBits);
this.cipher = initCipherForBlock(null, lastIndex);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java Thu Oct 21 17:34:29 2021
@@ -43,9 +43,6 @@ import org.apache.poi.util.TempFile;
@Internal
public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
private static final Logger LOG = LogManager.getLogger(ChunkedCipherOutputStream.class);
- //arbitrarily selected; may need to increase
- private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
- private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
private static final int STREAMING = -1;
@@ -66,25 +63,11 @@ public abstract class ChunkedCipherOutpu
private Cipher cipher;
private boolean isClosed;
- /**
- * @param length the max length allowed for ChunkedCipherOutputStream
- */
- public static void setMaxRecordLength(int length) {
- MAX_RECORD_LENGTH = length;
- }
-
- /**
- * @return the max length allowed for ChunkedCipherOutputStream
- */
- public static int getMaxRecordLength() {
- return MAX_RECORD_LENGTH;
- }
-
public ChunkedCipherOutputStream(DirectoryNode dir, int chunkSize) throws IOException, GeneralSecurityException {
super(null);
this.chunkSize = chunkSize;
int cs = chunkSize == STREAMING ? 4096 : chunkSize;
- this.chunk = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
+ this.chunk = IOUtils.safelyAllocate(cs, CryptoFunctions.MAX_RECORD_LENGTH);
this.plainByteFlags = new SparseBitSet(cs);
this.chunkBits = Integer.bitCount(cs-1);
this.fileOut = TempFile.createTempFile("encrypted_package", "crypt");
@@ -98,7 +81,7 @@ public abstract class ChunkedCipherOutpu
super(stream);
this.chunkSize = chunkSize;
int cs = chunkSize == STREAMING ? 4096 : chunkSize;
- this.chunk = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
+ this.chunk = IOUtils.safelyAllocate(cs, CryptoFunctions.MAX_RECORD_LENGTH);
this.plainByteFlags = new SparseBitSet(cs);
this.chunkBits = Integer.bitCount(cs-1);
this.fileOut = null;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java?rev=1894453&r1=1894452&r2=1894453&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java Thu Oct 21 17:34:29 2021
@@ -47,7 +47,22 @@ import org.apache.poi.util.StringUtil;
public final class CryptoFunctions {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+ /**
+ * @param length the max record length allowed for CryptoFunctions
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max record length allowed for CryptoFunctions
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
private CryptoFunctions() {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org