           (dolist (enclosure-index attachnums)
             (let* ((url-enclosure
                     (aref (elfeed-entry-enclosures entry) enclosure-index))
-                   (fname (file-name-nondirectory
-                           (url-unhex-string
-                            (car (url-path-and-query
-                                  (url-generic-parse-url url-enclosure))))))
+                   (fname
+                    (funcall elfeed-show-enclosure-filename-function
+                             entry url-enclosure))
                    (retry t))
               (while retry
                 (setf fpath (expand-file-name (concat attachdir fname) path)

    (if (file-directory-p fpath)
        fpath)))

(defun elfeed-show-save-enclosure-single (&optional entry enclosure-index)
  "Save enclosure number ENCLOSURE-INDEX from ENTRY.
If ENTRY is nil use the elfeed-show-entry variable.

                               "Enclosure to save" entry)))
         (url-enclosure (car (elt (elfeed-entry-enclosures entry)
                                  (- enclosure-index 1))))
         (fname
          (funcall elfeed-show-enclosure-filename-function
                   entry url-enclosure))
         (retry t)
         (fpath))
    (while retry
