Skip to content

Commit

Permalink
exif: Allow more spacing characters in strings
Browse files Browse the repository at this point in the history
The root cause of issue #8079 was a non-breaking space (U+0160).
`unicode.IsPrint` only allows the ASCII space (U+0020).  Be more lenient
by using `unicode.IsGraphic` instead.

Fixes #8079
  • Loading branch information
moorereason authored and bep committed Mar 13, 2021
1 parent 4d24e2a commit 0a2ab3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/images/exif/exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (e *exifWalker) Walk(f _exif.FieldName, tag *tiff.Tag) error {
func nullString(in []byte) string {
var rv bytes.Buffer
for _, b := range in {
if unicode.IsPrint(rune(b)) {
if unicode.IsGraphic(rune(b)) {
rv.WriteByte(b)
}
}
Expand Down
14 changes: 14 additions & 0 deletions resources/images/exif/exif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ func TestExifPNG(t *testing.T) {
c.Assert(err, qt.Not(qt.IsNil))
}

func TestIssue8079(t *testing.T) {
c := qt.New(t)

f, err := os.Open(filepath.FromSlash("../../testdata/iss8079.jpg"))
c.Assert(err, qt.IsNil)
defer f.Close()

d, err := NewDecoder()
c.Assert(err, qt.IsNil)
x, err := d.Decode(f)
c.Assert(err, qt.IsNil)
c.Assert(x.Tags["ImageDescription"], qt.Equals, "Città del Vaticano #nanoblock #vatican #vaticancity")
}

func BenchmarkDecodeExif(b *testing.B) {
c := qt.New(b)
f, err := os.Open(filepath.FromSlash("../../testdata/sunset.jpg"))
Expand Down
Binary file added resources/testdata/iss8079.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a2ab3f

Please sign in to comment.