Skip to content

Commit

Permalink
ItemInfoBox no longer throws exception when no content encoding is pr…
Browse files Browse the repository at this point in the history
…esent
  • Loading branch information
normana10 committed Apr 30, 2020
1 parent f65e53a commit f587113
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Source/com/drew/metadata/heif/boxes/ItemInfoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ public ItemInfoEntry(SequentialReader reader, Box box) throws IOException
{
super(reader, box);

// 4 Bytes for length, 4 Bytes for type. Reader is indexed from AFTER type but box.size INCLUDES the aforementioned 8 bytes
int headerLength = 8;

if ((version == 0) || (version == 1)) {
itemID = reader.getUInt16();
itemProtectionIndex = reader.getUInt16();
itemName = reader.getNullTerminatedString((int)(box.size - reader.getPosition()), Charsets.UTF_8);
contentType = reader.getNullTerminatedString((int)(box.size - reader.getPosition()), Charsets.UTF_8);
if (box.size - reader.getPosition() > 0) {
extensionType = reader.getNullTerminatedString((int) (box.size - reader.getPosition()), Charsets.UTF_8);
itemName = reader.getNullTerminatedString((int)(box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
contentType = reader.getNullTerminatedString((int)(box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
if (box.size - reader.getPosition() - headerLength > 0) {
extensionType = reader.getNullTerminatedString((int) (box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
}
}
if (version == 1) {
Expand All @@ -92,14 +95,14 @@ public ItemInfoEntry(SequentialReader reader, Box box) throws IOException
itemProtectionIndex = reader.getUInt16();
itemType = reader.getString(4);

itemName = reader.getNullTerminatedString((int)(box.size - reader.getPosition()), Charsets.UTF_8);
itemName = reader.getNullTerminatedString((int)(box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
if (itemType.equals("mime")) {
contentType = reader.getNullTerminatedString((int)(box.size - reader.getPosition()), Charsets.UTF_8);
if (box.size - reader.getPosition() > 0) {
contentEncoding = reader.getNullTerminatedString((int)(box.size - reader.getPosition()), Charsets.UTF_8);
contentType = reader.getNullTerminatedString((int)(box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
if (box.size - reader.getPosition() - headerLength > 0) {
contentEncoding = reader.getNullTerminatedString((int)(box.size - reader.getPosition() - headerLength), Charsets.UTF_8);
}
} else if (itemType.equals("uri ")) {
itemUriType = reader.getString((int)(box.size - reader.getPosition()));
itemUriType = reader.getString((int)(box.size - reader.getPosition() - headerLength));
}
}
}
Expand Down

0 comments on commit f587113

Please sign in to comment.