summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2021-03-13 09:21:30 -0600
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-03-13 21:20:10 +0100
commit0a2ab3f8feb961f8394b1f9964fab36bfa468027 (patch)
tree15f7f41a2bb9f657de2d6c39e5c948a8a9281492 /resources
parent4d24e2a3261d8c7dc0395db3ac4de89ebb0974a5 (diff)
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 (limited to 'resources')
-rw-r--r--resources/images/exif/exif.go2
-rw-r--r--resources/images/exif/exif_test.go14
-rw-r--r--resources/testdata/iss8079.jpgbin0 -> 116955 bytes
3 files changed, 15 insertions, 1 deletions
diff --git a/resources/images/exif/exif.go b/resources/images/exif/exif.go
index 720d200c9..065c14355 100644
--- 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
index 12e3b7f71..69540ddf5 100644
--- 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
new file mode 100644
index 000000000..a9049e81b
--- /dev/null
+++ b/resources/testdata/iss8079.jpg
Binary files differ