diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-10-24 09:37:50 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-10-24 09:37:50 +0000 |
commit | 977a8708999a14e4797f5bca030f9ff1598aa97a (patch) | |
tree | dbca43c5d545918b60bccc994ee021b54a6f7497 | |
parent | e823df80293490f6d6763e089ab3e74887da25b8 (diff) | |
download | poi-977a8708999a14e4797f5bca030f9ff1598aa97a.tar.gz poi-977a8708999a14e4797f5bca030f9ff1598aa97a.zip |
configurable max record len
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894526 13f79535-47bb-0310-9956-ffa450edef68
7 files changed, 83 insertions, 11 deletions
diff --git a/poi-excelant/src/main/java9/module-info.class b/poi-excelant/src/main/java9/module-info.class Binary files differindex bb1e0378df..271b567453 100644 --- a/poi-excelant/src/main/java9/module-info.class +++ b/poi-excelant/src/main/java9/module-info.class diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SoundData.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SoundData.java index f51e059a21..57561abd3e 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SoundData.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SoundData.java @@ -34,7 +34,22 @@ public final class SoundData extends RecordAtom { //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; + + /** + * @param length the max record length allowed for SoundData + */ + public static void setMaxRecordLength(int length) { + MAX_RECORD_LENGTH = length; + } + + /** + * @return the max record length allowed for SoundData + */ + public static int getMaxRecordLength() { + return MAX_RECORD_LENGTH; + } /** * Record header. diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java index 6f72d28650..f81c7dd49c 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfText.java @@ -49,7 +49,22 @@ import org.apache.poi.util.LocaleUtil; public class HwmfText { private static final Logger LOG = LogManager.getLogger(HwmfText.class); - 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 HwmfText + */ + public static void setMaxRecordLength(int length) { + MAX_RECORD_LENGTH = length; + } + + /** + * @return the max record length allowed for HwmfText + */ + public static int getMaxRecordLength() { + return MAX_RECORD_LENGTH; + } /** * The META_SETTEXTCHAREXTRA record defines inter-character spacing for text justification in the diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java index 66c3b51bcc..08815263cf 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java @@ -67,7 +67,22 @@ public abstract class HWPFDocumentCore extends POIDocument { protected static final String STREAM_TABLE_1 = "1Table"; //arbitrarily selected; may need to increase - private static final int MAX_RECORD_LENGTH = 500_000_000; + private static final int DEFAULT_MAX_RECORD_LENGTH = 500_000_000; + private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH; + + /** + * @param length the max record length allowed for HWPFDocumentCore + */ + public static void setMaxRecordLength(int length) { + MAX_RECORD_LENGTH = length; + } + + /** + * @return the max record length allowed for HWPFDocumentCore + */ + public static int getMaxRecordLength() { + return MAX_RECORD_LENGTH; + } /** * Size of the not encrypted part of the FIB diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java index a5a3d441cb..fa2310b7ef 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java @@ -46,15 +46,29 @@ import org.apache.poi.util.NotImplemented; import org.apache.poi.util.StringUtil; /** - * Provides very simple support for old (Word 6 / Word 95) - * files. + * Provides very simple support for old (Word 6 / Word 95) files. */ public class HWPFOldDocument extends HWPFDocumentCore { private static final Logger LOG = LogManager.getLogger(HWPFOldDocument.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; + + /** + * @param length the max record length allowed for HWPFOldDocument + */ + public static void setMaxRecordLength(int length) { + MAX_RECORD_LENGTH = length; + } + + /** + * @return the max record length allowed for HWPFOldDocument + */ + public static int getMaxRecordLength() { + return MAX_RECORD_LENGTH; + } private static final Charset DEFAULT_CHARSET = StringUtil.WIN_1252; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java index 478af6a272..384803469e 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java @@ -26,8 +26,6 @@ import org.apache.poi.util.Internal; @Internal public class OldTextPieceTable extends TextPieceTable { - //arbitrarily selected; may need to increase - private static final int MAX_RECORD_LENGTH = 100_000_000; public OldTextPieceTable() { super(); @@ -82,7 +80,7 @@ public class OldTextPieceTable extends TextPieceTable { int textSizeBytes = textSizeChars * multiple; // Grab the data that makes up the piece - byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, MAX_RECORD_LENGTH); + byte[] buf = IOUtils.safelyClone(documentStream, start, textSizeBytes, getMaxRecordLength()); // And now build the piece final TextPiece newTextPiece = newTextPiece(nodeStartChars, nodeEndChars, buf, pieces[x]); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java index 5f8c4da5ee..ded50c1357 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java @@ -36,13 +36,28 @@ import static org.apache.logging.log4j.util.Unbox.box; /** * The piece table for matching up character positions to bits of text. This * mostly works in bytes, but the TextPieces themselves work in characters. This - * does the icky convertion. + * does the icky conversion. */ @Internal public class TextPieceTable implements CharIndexTranslator { private static final Logger LOG = LogManager.getLogger(TextPieceTable.class); //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; + + /** + * @param length the max record length allowed for TextPieceTable + */ + public static void setMaxRecordLength(int length) { + MAX_RECORD_LENGTH = length; + } + + /** + * @return the max record length allowed for TextPieceTable + */ + public static int getMaxRecordLength() { + return MAX_RECORD_LENGTH; + } // int _multiple; |