aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-21 16:52:09 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-21 16:52:09 +0000
commitdbc6576da49b02c5cfab100b99d48c449f445222 (patch)
tree7eaac8ea2f99f2840d8d93789258ce3487040e61 /poi
parent0727874584371a02fe3d5c40cdebf668cdb6ee29 (diff)
downloadpoi-dbc6576da49b02c5cfab100b99d48c449f445222.tar.gz
poi-dbc6576da49b02c5cfab100b99d48c449f445222.zip
make max record sizes configurable
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894452 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java19
-rw-r--r--poi/src/main/java/org/apache/poi/hpsf/Blob.java17
-rw-r--r--poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java17
-rw-r--r--poi/src/main/java/org/apache/poi/hpsf/CodePageString.java16
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java17
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java17
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java17
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java17
-rw-r--r--poi/src/main/java/org/apache/poi/util/LZWDecompresser.java17
-rw-r--r--poi/src/main/java/org/apache/poi/util/StringUtil.java17
16 files changed, 256 insertions, 17 deletions
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java b/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java
index 08f3a0c694..0d6ad788fa 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherBSERecord.java
@@ -36,7 +36,8 @@ import org.apache.poi.util.LittleEndian;
public final class EscherBSERecord extends EscherRecord {
//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;
public static final short RECORD_ID = EscherRecordTypes.BSE.typeID;
@@ -55,6 +56,20 @@ public final class EscherBSERecord extends EscherRecord {
private byte[] _remainingData = new byte[0];
+ /**
+ * @param length the max length allowed for EscherBSERecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherBSERecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherBSERecord() {
setRecordId(RECORD_ID);
}
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java b/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java
index c9e6d73e5c..860798b6fe 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherBlipRecord.java
@@ -27,7 +27,8 @@ import org.apache.poi.util.LittleEndian;
public class EscherBlipRecord extends EscherRecord {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 104_857_600;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 104_857_600;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
public static final short RECORD_ID_START = EscherRecordTypes.BLIP_START.typeID;
public static final short RECORD_ID_END = EscherRecordTypes.BLIP_END.typeID;
@@ -36,6 +37,20 @@ public class EscherBlipRecord extends EscherRecord {
private byte[] field_pictureData;
+ /**
+ * @param length the max length allowed for EscherBlipRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherBlipRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherBlipRecord() {
}
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java b/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
index 5d182da247..b684014be5 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherClientAnchorRecord.java
@@ -36,7 +36,8 @@ import org.apache.poi.util.LittleEndian;
*/
public class EscherClientAnchorRecord extends EscherRecord {
//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;
public static final short RECORD_ID = EscherRecordTypes.CLIENT_ANCHOR.typeID;
@@ -60,6 +61,20 @@ public class EscherClientAnchorRecord extends EscherRecord {
private byte[] remainingData = new byte[0];
private boolean shortRecord;
+ /**
+ * @param length the max length allowed for EscherClientAnchorRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherClientAnchorRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherClientAnchorRecord() {}
public EscherClientAnchorRecord(EscherClientAnchorRecord other) {
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java b/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java
index 80f4f9e7e4..aab9249f8e 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherClientDataRecord.java
@@ -34,11 +34,26 @@ public class EscherClientDataRecord extends EscherRecord {
public static final short RECORD_ID = EscherRecordTypes.CLIENT_DATA.typeID;
//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 static final byte[] EMPTY = {};
private byte[] remainingData;
+ /**
+ * @param length the max length allowed for EscherClientDataRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherClientDataRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherClientDataRecord() {}
public EscherClientDataRecord(EscherClientDataRecord other) {
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java b/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java
index c5fac266e3..bb63ce40f5 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherMetafileBlip.java
@@ -41,7 +41,8 @@ import org.apache.poi.util.Removal;
public final class EscherMetafileBlip extends EscherBlipRecord {
private static final Logger LOGGER = LogManager.getLogger(EscherMetafileBlip.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;
/** @deprecated use EscherRecordTypes.BLIP_EMF.typeID */
@Deprecated
@@ -77,6 +78,20 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
private byte[] raw_pictureData;
private byte[] remainingData;
+ /**
+ * @param length the max length allowed for EscherMetafileBlip
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherMetafileBlip
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherMetafileBlip() {}
public EscherMetafileBlip(EscherMetafileBlip other) {
diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java b/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java
index dced174318..0105bc5c1e 100644
--- a/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java
+++ b/poi/src/main/java/org/apache/poi/ddf/EscherTextboxRecord.java
@@ -34,15 +34,30 @@ import org.apache.poi.util.RecordFormatException;
public final class EscherTextboxRecord extends EscherRecord {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ private static int DEFAULT_MAX_RECORD_LENGTH = 100_000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
public static final short RECORD_ID = EscherRecordTypes.CLIENT_TEXTBOX.typeID;
private static final byte[] NO_BYTES = new byte[0];
- /** The data for this record not including the the 8 byte header */
+ /** The data for this record not including the 8 byte header */
private byte[] thedata = NO_BYTES;
+ /**
+ * @param length the max length allowed for EscherTextboxRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherTextboxRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public EscherTextboxRecord() {}
public EscherTextboxRecord(EscherTextboxRecord other) {
diff --git a/poi/src/main/java/org/apache/poi/hpsf/Blob.java b/poi/src/main/java/org/apache/poi/hpsf/Blob.java
index 6c6e17c660..737462c667 100644
--- a/poi/src/main/java/org/apache/poi/hpsf/Blob.java
+++ b/poi/src/main/java/org/apache/poi/hpsf/Blob.java
@@ -24,10 +24,25 @@ import org.apache.poi.util.LittleEndianInput;
public class Blob {
//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[] _value;
+ /**
+ * @param length the max length allowed for Blob
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for Blob
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public void read( LittleEndianInput lei ) {
int size = lei.readInt();
_value = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
diff --git a/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java b/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java
index d92269a785..94e8edd3c2 100644
--- a/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java
+++ b/poi/src/main/java/org/apache/poi/hpsf/ClipboardData.java
@@ -29,13 +29,28 @@ import static org.apache.logging.log4j.util.Unbox.box;
@Internal
public class ClipboardData {
//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 Logger LOG = LogManager.getLogger(ClipboardData.class);
private int _format;
private byte[] _value;
+ /**
+ * @param length the max length allowed for ClipboardData
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for ClipboardData
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public void read( LittleEndianByteArrayInputStream lei ) {
int offset = lei.getReadIndex();
long size = lei.readInt();
diff --git a/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java b/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java
index 4ba9b0d063..ee2c69487a 100644
--- a/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java
+++ b/poi/src/main/java/org/apache/poi/hpsf/CodePageString.java
@@ -34,12 +34,26 @@ import static org.apache.logging.log4j.util.Unbox.box;
@Internal
public class CodePageString {
//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 static final Logger LOG = LogManager.getLogger(CodePageString.class);
private byte[] _value;
+ /**
+ * @param length the max length allowed for CodePageString
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for CodePageString
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
public void read( LittleEndianByteArrayInputStream lei ) {
int offset = lei.getReadIndex();
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
index 827ee4c0a7..c0ff0fc2d3 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
@@ -32,7 +32,8 @@ import org.apache.poi.util.LittleEndianInputStream;
public abstract class ChunkedCipherInputStream extends LittleEndianInputStream {
//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 int chunkSize;
private final int chunkBits;
@@ -45,6 +46,20 @@ public abstract class ChunkedCipherInputStream extends LittleEndianInputStream {
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);
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
index 9cd5c224ba..014a60c16d 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
@@ -44,7 +44,8 @@ import org.apache.poi.util.TempFile;
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 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 static final int STREAMING = -1;
@@ -65,6 +66,20 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
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;
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java b/poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
index 09a56e2e81..d83754c6f6 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
@@ -36,7 +36,22 @@ import org.apache.poi.util.StringUtil;
public class DataSpaceMapUtils {
//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;
+
+ /**
+ * @param length the max length allowed for EscherTextboxRecord
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EscherTextboxRecord
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
public static void addDefaultDataSpace(DirectoryEntry dir) throws IOException {
DataSpaceMapEntry dsme = new DataSpaceMapEntry(
diff --git a/poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java b/poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
index 47793a14c1..bfb4caabf5 100644
--- a/poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
+++ b/poi/src/main/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
@@ -58,7 +58,8 @@ import org.apache.poi.util.LocaleUtil;
public class EmbeddedExtractor implements Iterable<EmbeddedExtractor> {
private static final Logger LOG = LogManager.getLogger(EmbeddedExtractor.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;
// contentType
private static final String CONTENT_TYPE_BYTES = "binary/octet-stream";
@@ -67,6 +68,20 @@ public class EmbeddedExtractor implements Iterable<EmbeddedExtractor> {
private static final String CONTENT_TYPE_XLS = "application/vnd.ms-excel";
/**
+ * @param length the max length allowed for EmbeddedExtractor
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for EmbeddedExtractor
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
+ /**
* @return the list of known extractors, if you provide custom extractors, override this method
*/
@Override
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java b/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
index 236546c3b4..a44379c37a 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
@@ -36,7 +36,8 @@ import org.apache.poi.util.IOUtils;
final class FunctionMetadataReader {
//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 static final String METADATA_FILE_NAME = "functionMetadata.txt";
private static final String METADATA_FILE_NAME_CETAB = "functionMetadataCetab.txt";
@@ -55,6 +56,20 @@ final class FunctionMetadataReader {
};
private static final Set<String> DIGIT_ENDING_FUNCTION_NAMES_SET = new HashSet<>(Arrays.asList(DIGIT_ENDING_FUNCTION_NAMES));
+ /**
+ * @param length the max length allowed for FunctionMetadataReader
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for FunctionMetadataReader
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
public static FunctionMetadataRegistry createRegistry() {
FunctionDataBuilder fdb = new FunctionDataBuilder(800);
readResourceFile(fdb, METADATA_FILE_NAME);
diff --git a/poi/src/main/java/org/apache/poi/util/LZWDecompresser.java b/poi/src/main/java/org/apache/poi/util/LZWDecompresser.java
index 1a0052e08b..1fc9573ee0 100644
--- a/poi/src/main/java/org/apache/poi/util/LZWDecompresser.java
+++ b/poi/src/main/java/org/apache/poi/util/LZWDecompresser.java
@@ -40,7 +40,8 @@ public abstract class LZWDecompresser {
public static final int DICT_MASK = 0xFFF;
//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;
/**
* Does the mask bit mean it's compressed or uncompressed?
@@ -59,6 +60,20 @@ public abstract class LZWDecompresser {
*/
private final boolean positionIsBigEndian;
+ /**
+ * @param length the max length allowed for LZWDecompresser
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for LZWDecompresser
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
protected LZWDecompresser(boolean maskMeansCompressed,
int codeLengthIncrease, boolean positionIsBigEndian) {
this.maskMeansCompressed = maskMeansCompressed;
diff --git a/poi/src/main/java/org/apache/poi/util/StringUtil.java b/poi/src/main/java/org/apache/poi/util/StringUtil.java
index c635a536cd..c805dd4517 100644
--- a/poi/src/main/java/org/apache/poi/util/StringUtil.java
+++ b/poi/src/main/java/org/apache/poi/util/StringUtil.java
@@ -29,12 +29,27 @@ import java.util.Locale;
@Internal
public final class StringUtil {
//arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 10000000;
+ private static final int DEFAULT_MAX_RECORD_LENGTH = 10000000;
+ private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
public static final Charset UTF16LE = StandardCharsets.UTF_16LE;
public static final Charset UTF8 = StandardCharsets.UTF_8;
public static final Charset WIN_1252 = Charset.forName("cp1252");
+ /**
+ * @param length the max length allowed for StringUtil
+ */
+ public static void setMaxRecordLength(int length) {
+ MAX_RECORD_LENGTH = length;
+ }
+
+ /**
+ * @return the max length allowed for StringUtil
+ */
+ public static int getMaxRecordLength() {
+ return MAX_RECORD_LENGTH;
+ }
+
private StringUtil() {
// no instances of this class
}