emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/emms 8a55be19ba 06/42: Ignore empty Vorbis comments


From: ELPA Syncer
Subject: [elpa] externals/emms 8a55be19ba 06/42: Ignore empty Vorbis comments
Date: Wed, 1 Nov 2023 15:57:59 -0400 (EDT)

branch: externals/emms
commit 8a55be19baee7975c49f5ca84b4a72d80e120d84
Author: Petteri Hintsanen <petterih@iki.fi>
Commit: Petteri Hintsanen <petterih@iki.fi>

    Ignore empty Vorbis comments
---
 emms-info-native.el            | 11 ++++-------
 test/emms-info-native-tests.el |  6 +++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emms-info-native.el b/emms-info-native.el
index bbcbe494dc..a5d5219149 100644
--- a/emms-info-native.el
+++ b/emms-info-native.el
@@ -238,6 +238,7 @@ FIELDs that are listed in
 Vorbis comments are of form `FIELD=VALUE'.  FIELD is a
 case-insensitive field name with a restricted set of ASCII
 characters.  VALUE is an arbitrary UTF-8 encoded octet stream.
+Comments with empty FIELD or VALUE are ignored.
 
 Return a cons cell (FIELD . VALUE), where FIELD is converted to
 lower case and VALUE is the decoded value."
@@ -246,7 +247,7 @@ lower case and VALUE is the decoded value."
                                                comment
                                                nil)
                                               'utf-8)))
-    (when (string-match "^\\(.+?\\)=\\(.+?\\)$" comment-string)
+    (when (string-match "^\\(.+?\\)=\\(.+\\)$" comment-string)
       (cons (downcase (match-string 1 comment-string))
             (match-string 2 comment-string)))))
 
@@ -1081,12 +1082,8 @@ Supports Ogg Vorbis/Opus, FLAC, and MP3 files."
        (dolist (field info-fields)
          (let ((name (intern (concat "info-" (car field))))
                (value (cdr field)))
-            (unless (zerop (length value))
-              (emms-track-set track
-                              name
-                              (if (eq name 'info-playing-time)
-                                 (string-to-number value)
-                               (string-trim-right value)))))))
+            (when (stringp value) (setq value (string-trim-right value)))
+            (emms-track-set track name value))))
     (error (message "emms-info-native error processing %s: %s"
                    (emms-track-name track) env))))
 
diff --git a/test/emms-info-native-tests.el b/test/emms-info-native-tests.el
index 318d966fea..952624c4d1 100644
--- a/test/emms-info-native-tests.el
+++ b/test/emms-info-native-tests.el
@@ -1,5 +1,6 @@
 ;; -*- lexical-binding: t; -*-
 
+(require 'emms-info-native)
 (require 'ert)
 
 (ert-deftest emms-test-extract-vorbis-comments ()
@@ -20,7 +21,10 @@
     (should (equal (emms-info-native--split-vorbis-comment "x") nil))
     (should (equal (emms-info-native--split-vorbis-comment "x=") nil))
     (should (equal (emms-info-native--split-vorbis-comment "=x") nil))
-    (should (equal (emms-info-native--split-vorbis-comment "a=B") (cons "a" 
"B")))
+    (should (equal (emms-info-native--split-vorbis-comment "a=B")
+                   (cons "a" "B")))
+    (should (equal (emms-info-native--split-vorbis-comment "abc=ABC=123")
+                   (cons "abc" "ABC=123")))
     (should (equal (emms-info-native--split-vorbis-comment utf-8-comment)
                    (cons "key" "Οὐχὶ Ταὐτὰ")))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]