mirror of
https://github.com/lyx0/yaf.git
synced 2024-11-13 19:49:53 +01:00
fix(exif): don't abort upload on missing EXIF data
We now correctly test the error type
This commit is contained in:
parent
ffb88d9a58
commit
16d9fa28dd
2 changed files with 7 additions and 4 deletions
|
@ -8,6 +8,9 @@ import (
|
||||||
exif "github.com/dsoprea/go-exif/v3"
|
exif "github.com/dsoprea/go-exif/v3"
|
||||||
exifcommon "github.com/dsoprea/go-exif/v3/common"
|
exifcommon "github.com/dsoprea/go-exif/v3/common"
|
||||||
jis "github.com/dsoprea/go-jpeg-image-structure/v2"
|
jis "github.com/dsoprea/go-jpeg-image-structure/v2"
|
||||||
|
// This is only needed for the log.Is() function to test error types. I would normally just
|
||||||
|
// reimplement this function privately but it is pulled in as an indirect dependency anyway.
|
||||||
|
exiflog "github.com/dsoprea/go-logging"
|
||||||
pis "github.com/dsoprea/go-png-image-structure/v2"
|
pis "github.com/dsoprea/go-png-image-structure/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ func (scrubber *ExifScrubber) ScrubExif(fileData []byte) ([]byte, error) {
|
||||||
segmentList := intfc.(*jis.SegmentList)
|
segmentList := intfc.(*jis.SegmentList)
|
||||||
rootIfd, _, err := segmentList.Exif()
|
rootIfd, _, err := segmentList.Exif()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == exif.ErrNoExif {
|
if exiflog.Is(err, exif.ErrNoExif) {
|
||||||
// Incoming data contained no EXIF in the first place so we can return the original
|
// Incoming data contained no EXIF in the first place so we can return the original
|
||||||
return fileData, nil
|
return fileData, nil
|
||||||
}
|
}
|
||||||
|
@ -71,7 +74,7 @@ func (scrubber *ExifScrubber) ScrubExif(fileData []byte) ([]byte, error) {
|
||||||
chunks := intfc.(*pis.ChunkSlice)
|
chunks := intfc.(*pis.ChunkSlice)
|
||||||
rootIfd, _, err := chunks.Exif()
|
rootIfd, _, err := chunks.Exif()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == exif.ErrNoExif {
|
if exiflog.Is(err, exif.ErrNoExif) {
|
||||||
// Incoming data contained no EXIF in the first place so we can return the original
|
// Incoming data contained no EXIF in the first place so we can return the original
|
||||||
return fileData, nil
|
return fileData, nil
|
||||||
}
|
}
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -5,16 +5,16 @@ go 1.19
|
||||||
require (
|
require (
|
||||||
github.com/dsoprea/go-exif/v3 v3.0.0-20210512043655-120bcdb2a55e
|
github.com/dsoprea/go-exif/v3 v3.0.0-20210512043655-120bcdb2a55e
|
||||||
github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20210512043942-b434301c6836
|
github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20210512043942-b434301c6836
|
||||||
|
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd
|
||||||
github.com/dsoprea/go-png-image-structure/v2 v2.0.0-20210512210324-29b889a6093d
|
github.com/dsoprea/go-png-image-structure/v2 v2.0.0-20210512210324-29b889a6093d
|
||||||
|
github.com/go-errors/errors v1.1.1
|
||||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/dsoprea/go-iptc v0.0.0-20200609062250-162ae6b44feb // indirect
|
github.com/dsoprea/go-iptc v0.0.0-20200609062250-162ae6b44feb // indirect
|
||||||
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
|
|
||||||
github.com/dsoprea/go-photoshop-info-format v0.0.0-20200609050348-3db9b63b202c // indirect
|
github.com/dsoprea/go-photoshop-info-format v0.0.0-20200609050348-3db9b63b202c // indirect
|
||||||
github.com/dsoprea/go-utility/v2 v2.0.0-20200717064901-2fccff4aa15e // indirect
|
github.com/dsoprea/go-utility/v2 v2.0.0-20200717064901-2fccff4aa15e // indirect
|
||||||
github.com/go-errors/errors v1.1.1 // indirect
|
|
||||||
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
|
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
|
||||||
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d // indirect
|
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d // indirect
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
|
||||||
|
|
Loading…
Reference in a new issue