mirror of https://github.com/apache/poi.git
more support for configurable max record len
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2730bdc113
commit
5b554e7534
|
@ -49,11 +49,26 @@ import org.apache.poi.util.IOUtils;
|
|||
|
||||
public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
|
||||
//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 final Deque<Iterator<?>> iterStack = new ArrayDeque<>();
|
||||
private Object current;
|
||||
|
||||
/**
|
||||
* @param length the max record length allowed for HemfEmbeddedIterator
|
||||
*/
|
||||
public static void setMaxRecordLength(int length) {
|
||||
MAX_RECORD_LENGTH = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max record length allowed for HemfEmbeddedIterator
|
||||
*/
|
||||
public static int getMaxRecordLength() {
|
||||
return MAX_RECORD_LENGTH;
|
||||
}
|
||||
|
||||
public HemfEmbeddedIterator(HemfPicture emf) {
|
||||
this(emf.getRecords().iterator());
|
||||
}
|
||||
|
|
|
@ -31,7 +31,22 @@ import org.apache.poi.util.IOUtils;
|
|||
public abstract class EscherPart extends HPBFPart {
|
||||
|
||||
//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 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;
|
||||
}
|
||||
|
||||
private EscherRecord[] records;
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ import org.apache.poi.util.LocaleUtil;
|
|||
*/
|
||||
public final class QuillContents extends HPBFPart {
|
||||
private static final Logger LOG = LogManager.getLogger(QuillContents.class);
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
|
||||
private final QCBit[] bits;
|
||||
|
@ -69,7 +67,7 @@ public final class QuillContents extends HPBFPart {
|
|||
int from = (int)LittleEndian.getUInt(data, offset+16);
|
||||
int len = (int)LittleEndian.getUInt(data, offset+20);
|
||||
|
||||
byte[] bitData = IOUtils.safelyClone(data, from, len, MAX_RECORD_LENGTH);
|
||||
byte[] bitData = IOUtils.safelyClone(data, from, len, EscherPart.getMaxRecordLength());
|
||||
|
||||
// Create
|
||||
if(bitType.equals("TEXT")) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.poi.hslf.blip;
|
|||
|
||||
import org.apache.poi.ddf.EscherBSERecord;
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.hslf.record.RecordAtom;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
@ -30,9 +31,6 @@ import org.apache.poi.util.Removal;
|
|||
*/
|
||||
public final class DIB extends Bitmap {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
/**
|
||||
* Size of the BITMAPFILEHEADER structure preceding the actual DIB bytes
|
||||
*/
|
||||
|
@ -118,7 +116,7 @@ public final class DIB extends Bitmap {
|
|||
LittleEndian.putInt(header, 10, offset);
|
||||
|
||||
//DIB data is the header + dib bytes
|
||||
byte[] dib = IOUtils.safelyAllocate(header.length + (long)data.length, MAX_RECORD_LENGTH);
|
||||
byte[] dib = IOUtils.safelyAllocate(header.length + (long)data.length, RecordAtom.getMaxRecordLength());
|
||||
System.arraycopy(header, 0, dib, 0, header.length);
|
||||
System.arraycopy(data, 0, dib, header.length, data.length);
|
||||
|
||||
|
|
|
@ -36,10 +36,6 @@ import org.apache.poi.util.StringUtil;
|
|||
|
||||
public final class CString extends RecordAtom {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
|
||||
private static int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private byte[] _header;
|
||||
|
||||
/** The bytes that make up the text */
|
||||
|
@ -50,20 +46,6 @@ public final class CString extends RecordAtom {
|
|||
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
|
||||
|
@ -103,7 +85,7 @@ public final class CString extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Grab the text
|
||||
_text = IOUtils.safelyClone(source,start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_text = IOUtils.safelyClone(source,start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
/**
|
||||
* Create an empty CString
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package org.apache.poi.hslf.record;
|
||||
|
||||
import static org.apache.logging.log4j.util.Unbox.box;
|
||||
import static org.apache.poi.hslf.record.RecordAtom.getMaxRecordLength;
|
||||
import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -44,11 +45,8 @@ import org.apache.poi.util.StringUtil;
|
|||
* PowerPoint document. Instead, it lives in a separate stream in the
|
||||
* document. As such, it has to be treated specially
|
||||
*/
|
||||
public class CurrentUserAtom
|
||||
{
|
||||
public class CurrentUserAtom {
|
||||
private static final Logger LOG = LogManager.getLogger(CurrentUserAtom.class);
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
/** Standard Atom header */
|
||||
private static final byte[] atomHeader = new byte[] { 0, 0, -10, 15 };
|
||||
|
@ -132,7 +130,7 @@ public class CurrentUserAtom
|
|||
|
||||
// Grab the contents
|
||||
try (InputStream in = dir.createDocumentInputStream("Current User")) {
|
||||
_contents = IOUtils.toByteArray(in, docProps.getSize(), MAX_RECORD_LENGTH);
|
||||
_contents = IOUtils.toByteArray(in, docProps.getSize(), getMaxRecordLength());
|
||||
}
|
||||
|
||||
// See how long it is. If it's under 28 bytes long, we can't
|
||||
|
@ -212,7 +210,7 @@ public class CurrentUserAtom
|
|||
// 4 = revision
|
||||
// 3 * len = ascii + unicode
|
||||
int size = 8 + 20 + 4 + (3 * lastEditUser.length());
|
||||
_contents = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
|
||||
_contents = IOUtils.safelyAllocate(size, getMaxRecordLength());
|
||||
|
||||
// First we have a 8 byte atom header
|
||||
System.arraycopy(atomHeader,0,_contents,0,4);
|
||||
|
@ -231,7 +229,7 @@ public class CurrentUserAtom
|
|||
|
||||
// The username gets stored twice, once as US
|
||||
// ascii, and again as unicode laster on
|
||||
byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), MAX_RECORD_LENGTH);
|
||||
byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), getMaxRecordLength());
|
||||
StringUtil.putCompressedUnicode(lastEditUser,asciiUN,0);
|
||||
|
||||
// Now we're able to do the length of the last edited user
|
||||
|
@ -253,7 +251,7 @@ public class CurrentUserAtom
|
|||
LittleEndian.putInt(_contents,28+asciiUN.length,(int)releaseVersion);
|
||||
|
||||
// username in unicode
|
||||
byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, MAX_RECORD_LENGTH);
|
||||
byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, getMaxRecordLength());
|
||||
StringUtil.putUnicodeLE(lastEditUser,ucUN,0);
|
||||
System.arraycopy(ucUN,0,_contents,28+asciiUN.length+4,ucUN.length);
|
||||
|
||||
|
|
|
@ -60,11 +60,6 @@ public final class DocumentAtom extends RecordAtom {
|
|||
}
|
||||
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
|
||||
|
||||
private final byte[] _header = new byte[8];
|
||||
private static final long _type = RecordTypes.DocumentAtom.typeID;
|
||||
|
||||
|
@ -111,13 +106,16 @@ public final class DocumentAtom extends RecordAtom {
|
|||
public int getFirstSlideNum() { return firstSlideNum; }
|
||||
|
||||
/**
|
||||
* The Size of the Document's slides, @see DocumentAtom.SlideSize for values
|
||||
* @deprecated to be replaced by enum
|
||||
* The Size of the Document's slides, {@link DocumentAtom.SlideSize} for values.
|
||||
*/
|
||||
public SlideSize getSlideSizeType() { return SlideSize.values()[slideSizeType]; }
|
||||
|
||||
/**
|
||||
* The Size of the Document's slides, {@link DocumentAtom.SlideSize} for values.
|
||||
* @deprecated replaced by {@link #getSlideSizeType()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Removal(version = "5.0.0")
|
||||
public int getSlideSizeType() { return slideSizeType; }
|
||||
|
||||
@Removal(version = "6.0.0")
|
||||
public SlideSize getSlideSizeTypeEnum() {
|
||||
return SlideSize.values()[slideSizeType];
|
||||
}
|
||||
|
@ -126,7 +124,7 @@ public final class DocumentAtom extends RecordAtom {
|
|||
slideSizeType = size.ordinal();
|
||||
}
|
||||
|
||||
/** Was the document saved with True Type fonts embeded? */
|
||||
/** Was the document saved with True Type fonts embedded? */
|
||||
public boolean getSaveWithFonts() {
|
||||
return saveWithFonts != 0;
|
||||
}
|
||||
|
@ -190,7 +188,7 @@ public final class DocumentAtom extends RecordAtom {
|
|||
showComments = leis.readByte();
|
||||
|
||||
// If there's any other bits of data, keep them about
|
||||
reserved = IOUtils.safelyAllocate(maxLen-48L, MAX_RECORD_LENGTH);
|
||||
reserved = IOUtils.safelyAllocate(maxLen-48L, getMaxRecordLength());
|
||||
leis.readFully(reserved);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,6 @@ import org.apache.poi.util.LittleEndian;
|
|||
*/
|
||||
public class ExEmbedAtom extends RecordAtom {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
/**
|
||||
* Embedded document does not follow the color scheme.
|
||||
*/
|
||||
|
@ -96,7 +93,7 @@ public class ExEmbedAtom extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Get the record data.
|
||||
_data = IOUtils.safelyClone(source,start+8,len-8, MAX_RECORD_LENGTH);
|
||||
_data = IOUtils.safelyClone(source,start+8,len-8, getMaxRecordLength());
|
||||
|
||||
// Must be at least 8 bytes long
|
||||
if(_data.length < 8) {
|
||||
|
|
|
@ -33,10 +33,7 @@ import org.apache.poi.util.LittleEndian;
|
|||
/**
|
||||
* An atom record that specifies information about external audio or video data.
|
||||
*/
|
||||
public final class ExMediaAtom extends RecordAtom
|
||||
{
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
public final class ExMediaAtom extends RecordAtom {
|
||||
|
||||
/**
|
||||
* A bit that specifies whether the audio or video data is repeated continuously during playback.
|
||||
|
@ -91,7 +88,7 @@ public final class ExMediaAtom extends RecordAtom
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Grab the record data
|
||||
_recdata = IOUtils.safelyClone(source,start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_recdata = IOUtils.safelyClone(source,start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,15 +29,10 @@ import org.apache.poi.util.IOUtils;
|
|||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* Tne atom that holds the seed info used by a ExObjList
|
||||
* The atom that holds the seed info used by a ExObjList
|
||||
*/
|
||||
|
||||
public class ExObjListAtom extends RecordAtom
|
||||
{
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
|
||||
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
|
||||
public class ExObjListAtom extends RecordAtom{
|
||||
|
||||
/**
|
||||
* Record header.
|
||||
|
@ -49,20 +44,6 @@ public class ExObjListAtom extends RecordAtom
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -89,7 +70,7 @@ public class ExObjListAtom extends RecordAtom
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Get the record data.
|
||||
_data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
|
||||
// Must be at least 4 bytes long
|
||||
if(_data.length < 4) {
|
||||
|
|
|
@ -42,9 +42,6 @@ import org.apache.poi.util.StringUtil;
|
|||
|
||||
public final class FontEntityAtom extends RecordAtom {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private static final int[] FLAGS_MASKS = {
|
||||
0x0001, 0x0100, 0x0200, 0x0400, 0x0800
|
||||
};
|
||||
|
@ -75,7 +72,7 @@ public final class FontEntityAtom extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Grab the record data
|
||||
_recdata = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_recdata = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,9 +38,6 @@ import org.apache.poi.util.LittleEndian;
|
|||
*/
|
||||
public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private final List<org.apache.poi.hslf.record.Record> _childRecords = new ArrayList<>();
|
||||
|
||||
public HSLFEscherClientDataRecord() {}
|
||||
|
@ -68,7 +65,7 @@ public class HSLFEscherClientDataRecord extends EscherClientDataRecord {
|
|||
@Override
|
||||
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
|
||||
int bytesRemaining = readHeader( data, offset );
|
||||
byte[] remainingData = IOUtils.safelyClone(data, offset+8, bytesRemaining, MAX_RECORD_LENGTH);
|
||||
byte[] remainingData = IOUtils.safelyClone(data, offset+8, bytesRemaining, RecordAtom.getMaxRecordLength());
|
||||
setRemainingData(remainingData);
|
||||
return bytesRemaining + 8;
|
||||
}
|
||||
|
|
|
@ -32,11 +32,7 @@ import org.apache.poi.util.LittleEndian;
|
|||
* as what slide it is tied to
|
||||
*/
|
||||
|
||||
public final class NotesAtom extends RecordAtom
|
||||
{
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
public final class NotesAtom extends RecordAtom {
|
||||
|
||||
private byte[] _header;
|
||||
private static long _type = 1009l;
|
||||
|
@ -81,7 +77,7 @@ public final class NotesAtom extends RecordAtom
|
|||
followMasterObjects = (flags & 1) == 1;
|
||||
|
||||
// There might be 2 more bytes, which are a reserved field
|
||||
reserved = IOUtils.safelyClone(source, start+14, len-14, MAX_RECORD_LENGTH);
|
||||
reserved = IOUtils.safelyClone(source, start+14, len-14, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,26 @@ package org.apache.poi.hslf.record;
|
|||
* Abstract class which all atom records will extend.
|
||||
*/
|
||||
|
||||
public abstract class RecordAtom extends Record
|
||||
{
|
||||
public abstract class RecordAtom extends Record {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* We are an atom
|
||||
*/
|
||||
|
|
|
@ -38,9 +38,6 @@ public final class SlideAtom extends RecordAtom {
|
|||
public static final int USES_MASTER_SLIDE_ID = 0x80000000;
|
||||
// private static final int MASTER_SLIDE_ID = 0x00000000;
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private byte[] _header;
|
||||
private static long _type = 1007l;
|
||||
|
||||
|
@ -103,7 +100,7 @@ public final class SlideAtom extends RecordAtom {
|
|||
|
||||
// If there's any other bits of data, keep them about
|
||||
// 8 bytes header + 20 bytes to flags + 2 bytes flags = 30 bytes
|
||||
reserved = IOUtils.safelyClone(source,start+30, len-30, MAX_RECORD_LENGTH);
|
||||
reserved = IOUtils.safelyClone(source,start+30, len-30, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,8 +52,6 @@ import org.apache.poi.util.LittleEndian;
|
|||
|
||||
public final class StyleTextPropAtom extends RecordAtom {
|
||||
public static final long _type = RecordTypes.StyleTextPropAtom.typeID;
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private final byte[] _header;
|
||||
private byte[] reserved;
|
||||
|
@ -136,7 +134,7 @@ public final class StyleTextPropAtom extends RecordAtom {
|
|||
|
||||
// Save the contents of the atom, until we're asked to go and
|
||||
// decode them (via a call to setParentTextSize(int)
|
||||
rawContents = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
rawContents = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
reserved = new byte[0];
|
||||
|
||||
// Set empty lists, ready for when they call setParentTextSize
|
||||
|
@ -401,7 +399,7 @@ public final class StyleTextPropAtom extends RecordAtom {
|
|||
|
||||
out.append(" original byte stream \n");
|
||||
|
||||
byte[] buf = IOUtils.safelyAllocate(rawContents.length + (long)reserved.length, MAX_RECORD_LENGTH);
|
||||
byte[] buf = IOUtils.safelyAllocate(rawContents.length + (long)reserved.length, getMaxRecordLength());
|
||||
System.arraycopy(rawContents, 0, buf, 0, rawContents.length);
|
||||
System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
|
||||
out.append( HexDump.dump(buf, 0, 0) );
|
||||
|
|
|
@ -38,8 +38,6 @@ import org.apache.poi.util.StringUtil;
|
|||
|
||||
public final class TextBytesAtom extends RecordAtom {
|
||||
public static final long _type = RecordTypes.TextBytesAtom.typeID;
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private byte[] _header;
|
||||
|
||||
|
@ -73,7 +71,7 @@ public final class TextBytesAtom extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Grab the text
|
||||
_text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_text = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.apache.poi.util.StringUtil;
|
|||
|
||||
public final class TextCharsAtom extends RecordAtom {
|
||||
public static final long _type = RecordTypes.TextCharsAtom.typeID;
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
private byte[] _header;
|
||||
|
||||
|
@ -52,7 +50,7 @@ public final class TextCharsAtom extends RecordAtom {
|
|||
/** Updates the text in the Atom. */
|
||||
public void setText(String text) {
|
||||
// Convert to little endian unicode
|
||||
_text = IOUtils.safelyAllocate(text.length() * 2L, MAX_RECORD_LENGTH);
|
||||
_text = IOUtils.safelyAllocate(text.length() * 2L, getMaxRecordLength());
|
||||
StringUtil.putUnicodeLE(text,_text,0);
|
||||
|
||||
// Update the size (header bytes 5-8)
|
||||
|
@ -72,7 +70,7 @@ public final class TextCharsAtom extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Grab the text
|
||||
_text = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_text = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
/**
|
||||
* Create an empty TextCharsAtom
|
||||
|
|
|
@ -35,9 +35,6 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
|||
|
||||
public class TextSpecInfoRun implements GenericRecord {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
/**
|
||||
* A enum that specifies the spelling status of a run of text.
|
||||
*/
|
||||
|
@ -176,7 +173,7 @@ public class TextSpecInfoRun implements GenericRecord {
|
|||
if (smartTagFld.isSet(mask)) {
|
||||
// An unsigned integer specifies the count of items in rgSmartTagIndex.
|
||||
int count = source.readInt();
|
||||
smartTagsBytes = IOUtils.safelyAllocate(4 + count * 4L, MAX_RECORD_LENGTH);
|
||||
smartTagsBytes = IOUtils.safelyAllocate(4 + count * 4L, RecordAtom.getMaxRecordLength());
|
||||
LittleEndian.putInt(smartTagsBytes, 0, count);
|
||||
// An array of SmartTagIndex that specifies the indices.
|
||||
// The count of items in the array is specified by count.
|
||||
|
|
|
@ -32,9 +32,6 @@ import org.apache.poi.util.LittleEndian;
|
|||
*/
|
||||
public final class TxInteractiveInfoAtom extends RecordAtom {
|
||||
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int MAX_RECORD_LENGTH = 1_000_000;
|
||||
|
||||
/**
|
||||
* Record header.
|
||||
*/
|
||||
|
@ -69,7 +66,7 @@ public final class TxInteractiveInfoAtom extends RecordAtom {
|
|||
_header = Arrays.copyOfRange(source, start, start+8);
|
||||
|
||||
// Get the record data.
|
||||
_data = IOUtils.safelyClone(source, start+8, len-8, MAX_RECORD_LENGTH);
|
||||
_data = IOUtils.safelyClone(source, start+8, len-8, getMaxRecordLength());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class TestDocumentAtom {
|
|||
void testSlideDetails() {
|
||||
DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length);
|
||||
assertEquals(1, da.getFirstSlideNum());
|
||||
assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeTypeEnum());
|
||||
assertEquals(DocumentAtom.SlideSize.ON_SCREEN, da.getSlideSizeType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue