commit 0a2ab3f8feb961f8394b1f9964fab36bfa468027
parent 4d24e2a3261d8c7dc0395db3ac4de89ebb0974a5
Author: Cameron Moore <moorereason@gmail.com>
Date: Sat, 13 Mar 2021 09:21:30 -0600
exif: Allow more spacing characters in strings
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
Diffstat:
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/resources/images/exif/exif.go b/resources/images/exif/exif.go
@@ -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)
}
}
diff --git a/resources/images/exif/exif_test.go b/resources/images/exif/exif_test.go
@@ -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
Binary files differ.