mirror of https://github.com/dsoprea/go-exif.git
v2/common/parser.go: Revert to previous NUL forgiveness
It turns out that there is so much loose handling with the terminating NUL characters out there that there's a societal breakdown without this. Fixes #31for/master
parent
bc34ca087b
commit
bd04addaf4
|
@ -8,6 +8,10 @@ import (
|
||||||
"github.com/dsoprea/go-logging"
|
"github.com/dsoprea/go-logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
parserLogger = log.NewLogger("exifcommon.parser")
|
||||||
|
)
|
||||||
|
|
||||||
// Parser knows how to parse all well-defined, encoded EXIF types.
|
// Parser knows how to parse all well-defined, encoded EXIF types.
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
}
|
}
|
||||||
|
@ -50,8 +54,10 @@ func (p *Parser) ParseAscii(data []byte, unitCount uint32) (value string, err er
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 0 || data[count-1] != 0 {
|
if len(data) == 0 || data[count-1] != 0 {
|
||||||
log.Panicf("ascii not terminated with nul as expected")
|
s := string(data[:count])
|
||||||
return "", nil
|
parserLogger.Warningf(nil, "ascii not terminated with nul as expected: [%v]", s)
|
||||||
|
|
||||||
|
return s, nil
|
||||||
} else {
|
} else {
|
||||||
// Auto-strip the NUL from the end. It serves no purpose outside of
|
// Auto-strip the NUL from the end. It serves no purpose outside of
|
||||||
// encoding semantics.
|
// encoding semantics.
|
||||||
|
|
Loading…
Reference in New Issue