]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix yank-media-types--format decoding
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 5 Feb 2022 06:00:50 +0000 (07:00 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 5 Feb 2022 06:01:00 +0000 (07:01 +0100)
* lisp/yank-media.el (yank-media-types--format): Check that we
really have some nuls.

lisp/yank-media.el

index 9836082fb2a74c360fc2cbbf8e76782905004212..8c758777247f3e723128c86ed137cc48c93d791b 100644 (file)
@@ -162,23 +162,26 @@ non-supported selection data types."
                     (when (zerop (elt data i))
                       (setf (aref stats (mod i 2))
                             (1+ (aref stats (mod i 2))))))
-                  ;; If we have more than 90% every-other nul, then it's
-                  ;; pretty likely to be utf-16.
-                  (cond
-                   ((> (if (zerop (elt stats 1))
-                           1
-                         (/ (float (elt stats 0))
-                            (float (elt stats 1))))
-                       0.9)
-                    ;; Big endian.
-                    'utf-16-be)
-                   ((> (if (zerop (elt stats 0))
-                           1
-                         (/ (float (elt stats 1))
-                            (float (elt stats 0))))
-                       0.9)
-                    ;; Little endian.
-                    'utf-16-le))))))
+                  ;; We have some nuls...
+                  (and (not (and (zerop (elt stats 0))
+                                 (zerop (elt stats 1))))
+                       ;; If we have more than 90% every-other nul, then it's
+                       ;; pretty likely to be utf-16.
+                       (cond
+                        ((> (if (zerop (elt stats 1))
+                                1
+                              (/ (float (elt stats 0))
+                                 (float (elt stats 1))))
+                            0.9)
+                         ;; Big endian.
+                         'utf-16-be)
+                        ((> (if (zerop (elt stats 0))
+                                1
+                              (/ (float (elt stats 1))
+                                 (float (elt stats 0))))
+                            0.9)
+                         ;; Little endian.
+                         'utf-16-le)))))))
       (if coding-system
           (decode-coding-string data coding-system)
         ;; Some programs add a nul character at the end of text/*