mirror of
https://github.com/dsoprea/go-exif.git
synced 2025-05-31 11:41:57 +00:00
ifd_enumerate: Properly handle unknown-type tags during the initial parse.
This commit is contained in:
parent
cda05ba702
commit
4c3a9d79f1
@ -194,8 +194,14 @@ func (ie *IfdEnumerate) resolveTagValue(ite *IfdTagEntry) (valueBytes []byte, is
|
||||
}
|
||||
|
||||
value, err := UndefinedValue(ite.Ii, ite.TagId, valueContext, ie.byteOrder)
|
||||
log.PanicIf(err)
|
||||
|
||||
if err != nil {
|
||||
if log.Is(err, ErrUnhandledUnknownTypedTag) == true {
|
||||
valueBytes = []byte(UnparseableUnknownTagValuePlaceholder)
|
||||
return valueBytes, true, nil
|
||||
} else {
|
||||
log.Panic(err)
|
||||
}
|
||||
} else {
|
||||
switch value.(type) {
|
||||
case []byte:
|
||||
return value.([]byte), false, nil
|
||||
@ -203,9 +209,6 @@ func (ie *IfdEnumerate) resolveTagValue(ite *IfdTagEntry) (valueBytes []byte, is
|
||||
return []byte(value.(string)), false, nil
|
||||
case UnknownTagValue:
|
||||
valueBytes, err := value.(UnknownTagValue).ValueBytes()
|
||||
|
||||
// TODO(dustin): Is this always bytes? What about the tag-specific structures that are built? Handle unhandled unknown. Set isUnhandledUnknown.
|
||||
|
||||
log.PanicIf(err)
|
||||
|
||||
return valueBytes, false, nil
|
||||
@ -214,7 +217,7 @@ func (ie *IfdEnumerate) resolveTagValue(ite *IfdTagEntry) (valueBytes []byte, is
|
||||
log.Panicf("can not produce bytes for unknown-type tag (0x%04x): [%s]", ite.TagId, reflect.TypeOf(value))
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
originalType := NewTagType(ite.TagType, ie.byteOrder)
|
||||
byteCount := uint32(originalType.Size()) * ite.UnitCount
|
||||
|
||||
@ -233,6 +236,7 @@ func (ie *IfdEnumerate) resolveTagValue(ite *IfdTagEntry) (valueBytes []byte, is
|
||||
valueBytes, err = tt.ParseBytes(addressableData[ite.ValueOffset:], byteCount)
|
||||
log.PanicIf(err)
|
||||
}
|
||||
}
|
||||
|
||||
return valueBytes, false, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user