exif: Allow more spacing characters in strings
authorCameron Moore <moorereason@gmail.com>
Sat, 13 Mar 2021 15:21:30 +0000 (09:21 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 13 Mar 2021 20:20:10 +0000 (21:20 +0100)
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

resources/images/exif/exif.go
resources/images/exif/exif_test.go
resources/testdata/iss8079.jpg [new file with mode: 0644]

index 720d200c9df18a3cc9801af3e9d90a08f5041cd2..065c143554f2f1c266f620d456f420be2038da1f 100644 (file)
@@ -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)
                }
        }
index 12e3b7f71a0999d9b1d7f7604226054b97681b79..69540ddf5223180bc15db8515b14969a4254475e 100644 (file)
@@ -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"))
diff --git a/resources/testdata/iss8079.jpg b/resources/testdata/iss8079.jpg
new file mode 100644 (file)
index 0000000..a9049e8
Binary files /dev/null and b/resources/testdata/iss8079.jpg differ