From d801d1d8ccae3d8c9ea3d55c27ae16cd28212734 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 19 Mar 2020 16:15:04 +0100 Subject: [PATCH] Don't have exif bugging out on short strings * lisp/image/exif.el (exif--direct-ascii-value): New function (bug#40127). (exif--parse-directory): Use it to get the correct values for in-directory (i.e., shorter than 4 octets) strings. --- lisp/image/exif.el | 21 +++++++++++++++++++-- test/data/image/black-short.jpg | Bin 0 -> 31779 bytes test/lisp/image/exif-tests.el | 11 +++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/data/image/black-short.jpg diff --git a/lisp/image/exif.el b/lisp/image/exif.el index 642bc58321c..065456dc318 100644 --- a/lisp/image/exif.el +++ b/lisp/image/exif.el @@ -72,7 +72,8 @@ (283 y-resolution) (296 resolution-unit) (305 software) - (306 date-time)) + (306 date-time) + (315 artist)) "Alist of tag values and their names.") (defconst exif--orientation @@ -216,7 +217,10 @@ If the orientation isn't present in the data, return nil." (+ (1+ value) length))) ;; The value is stored directly ;; in the directory. - value) + (if (eq (car field-format) 'ascii) + (exif--direct-ascii-value + value (1- length) le) + value)) (car field-format) le))))) (let ((next (exif--read-number 4 le))) @@ -231,6 +235,19 @@ If the orientation isn't present in the data, return nil." ;; We've reached the end of the directories. dir)))) +(defun exif--direct-ascii-value (value bytes le) + "Make VALUE into a zero-terminated string. +VALUE is an integer representing BYTES characters." + (with-temp-buffer + (set-buffer-multibyte nil) + (if le + (dotimes (i bytes) + (insert (logand (lsh value (* i -8)) 255))) + (dotimes (i bytes) + (insert (logand (lsh value (* (- (1- bytes) i) -8)) 255)))) + (insert 0) + (buffer-string))) + (defun exif--process-value (value type le) "Do type-based post-processing of the value." (cl-case type diff --git a/test/data/image/black-short.jpg b/test/data/image/black-short.jpg new file mode 100644 index 0000000000000000000000000000000000000000..02a5b0b72ef1bd455173c093aa0f3a4cb3a0cf69 GIT binary patch literal 31779 zcmeHw4|r6?x%WG>XHRA~OZH^5EK8&~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