// Build up a tree of Escher records contained within
final DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
dgContainer.fillFields(source, start + 8, erf);
- assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
+ if (dgContainer.getRecordId() != EscherRecordTypes.DG_CONTAINER.typeID) {
+ throw new IllegalArgumentException("Unexpected record type: " + dgContainer.getRecordId());
+ }
dg = dgContainer.getChildById(EscherRecordTypes.DG.typeID);
textboxWrappers = Stream.of(dgContainer).
_header = Arrays.copyOfRange(source, ofs, ofs+8);
ofs += _header.length;
- assert(LittleEndian.getShort(_header, 0) == 0);
- assert(LittleEndian.getShort(_header, 2) == RecordTypes.SSSlideInfoAtom.typeID);
- assert(LittleEndian.getShort(_header, 4) == 0x10);
- assert(LittleEndian.getShort(_header, 6) == 0);
+ if (LittleEndian.getShort(_header, 0) != 0) {
+ LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 0: " + LittleEndian.getShort(_header, 0));
+ }
+ if (LittleEndian.getShort(_header, 2) != RecordTypes.SSSlideInfoAtom.typeID) {
+ LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 2: "+ LittleEndian.getShort(_header, 2));
+ }
+ if (LittleEndian.getShort(_header, 4) != 0x10) {
+ LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 4: "+ LittleEndian.getShort(_header, 4));
+ }
+ if (LittleEndian.getShort(_header, 6) == 0) {
+ LOG.atDebug().log("Invalid data for SSSlideInfoAtom at offset 6: "+ LittleEndian.getShort(_header, 6));
+ }
_slideTime = LittleEndian.getInt(source, ofs);
- assert(0 <= _slideTime && _slideTime <= 86399000);
+ if (_slideTime < 0 || _slideTime > 86399000) {
+ LOG.atDebug().log("Invalid data for SSSlideInfoAtom - invalid slideTime: "+ _slideTime);
+ }
ofs += LittleEndianConsts.INT_SIZE;
_soundIdRef = LittleEndian.getInt(source, ofs);
ofs += LittleEndianConsts.INT_SIZE;
offset += LittleEndianConsts.INT_SIZE;
}
- assert(offset-start == len);
+ if(offset-start != len) {
+ throw new HSLFException("Having invalid data in UserEditAtom: "
+ + "len: " + len + ", offset: " + offset + ", start: " + start);
+ }
}
/**
1, // unused2
1, // unused3
};
-
+
protected HSLFSlideShowEncrypted(DocumentEncryptionAtom dea) {
this.dea = dea;
}
r = Record.buildRecordAtOffset(docstream, encOffset);
recordMap.put(encOffset, r);
}
- assert(r instanceof DocumentEncryptionAtom);
- this.dea = (DocumentEncryptionAtom)r;
+
+ this.dea = (DocumentEncryptionAtom)r;
String pass = Biff8EncryptionKey.getCurrentUserPassword();
EncryptionInfo ei = getEncryptionInfo();
ccis.close();
lei.close();
}
-
+
protected void decryptPicture(byte[] pictstream, int offset) {
if (dea == null) {
return;
decryptPicBytes(pictstream, offset, part);
}
offset += 36;
-
+
int cbName = LittleEndian.getUShort(pictstream, offset-3);
if (cbName > 0) {
// read nameData
decryptPicBytes(pictstream, offset, cbName);
offset += cbName;
}
-
+
if (offset == endOffset) {
return; // no embedded blip
}
// tag
nextBytes = 1;
}
-
+
decryptPicBytes(pictstream, offset, nextBytes);
offset += nextBytes;
// File BLIP Store Entry (FBSE)
int cbName = LittleEndian.getUShort(pictstream, offset+33);
-
+
for (int part : BLIB_STORE_ENTRY_PARTS) {
ccos.write(pictstream, offset, part);
ccos.flush();
offset += part;
}
-
+
if (cbName > 0) {
ccos.write(pictstream, offset, cbName);
ccos.flush();
offset += cbName;
}
-
+
if (offset == endOffset) {
return; // no embedded blip
}
import java.util.List;
import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherRecord;
*/
@Internal
public final class OfficeArtContent {
+ protected static final Logger LOG = LogManager.getLogger(OfficeArtContent.class);
/**
* {@link EscherRecordTypes#DGG_CONTAINER} containing drawing group information for the document.
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
int pos = offset;
pos += drawingGroupData.fillFields(data, pos, recordFactory);
- assert drawingGroupData.getRecordId() == EscherRecordTypes.DGG_CONTAINER.typeID;
+ if (drawingGroupData.getRecordId() == EscherRecordTypes.DGG_CONTAINER.typeID) {
+ LOG.atDebug().log("Invalid record-id for filling Escher records: " + drawingGroupData.getRecordId());
+ }
/*
* After the drawingGroupData there is an array (2 slots max) that has data about drawings. According to the
// Named this way to match section 2.9.172 of [MS-DOC] - v20191119.
byte dgglbl = data[pos];
- assert dgglbl == 0x00 || dgglbl == 0x01;
+
+ if (dgglbl != 0x00 && dgglbl != 0x01) {
+ throw new IllegalArgumentException("Invalid dgglbl when filling Escher records: " + dgglbl);
+ }
pos++;
EscherContainerRecord dgContainer = new EscherContainerRecord();
pos+= dgContainer.fillFields(data, pos, recordFactory);
- assert dgContainer.getRecordId() == EscherRecordTypes.DG_CONTAINER.typeID;
+ if (dgContainer.getRecordId() != EscherRecordTypes.DG_CONTAINER.typeID) {
+ throw new IllegalArgumentException("Did have an invalid record-type: " + dgContainer.getRecordId() +
+ " when filling Escher records");
+ }
switch (dgglbl) {
case 0x00:
}
}
- assert pos == offset + size;
+ if (pos != offset + size) {
+ throw new IllegalStateException("Did not read all data when filling Escher records: "
+ + "pos: " + pos + ", offset: " + offset + ", size: " + size);
+ }
}
private List<? extends EscherContainerRecord> getDgContainers() {
nextRecord();
// note - the compressed flag may change on the fly
byte compressFlag = readByte();
- assert(compressFlag == 0 || compressFlag == 1);
+ if (compressFlag != 0 && compressFlag != 1) {
+ throw new RecordFormatException("Invalid compressFlag: " + compressFlag);
+ }
isCompressedEncoding = (compressFlag == 0);
}
}