Ignore epg-package-info.el.
[elisp/epg.git] / epg.el
diff --git a/epg.el b/epg.el
index 491ef30..0b4d7ca 100644 (file)
--- a/epg.el
+++ b/epg.el
@@ -1095,6 +1095,8 @@ This function is for internal use only."
                           epg-gpg-program)
                          (mapconcat #'identity args " ")))))
     (with-current-buffer buffer
+      (if (fboundp 'set-buffer-multibyte)
+         (set-buffer-multibyte nil))
       (make-local-variable 'epg-last-status)
       (setq epg-last-status nil)
       (make-local-variable 'epg-read-point)
@@ -1196,6 +1198,11 @@ This function is for internal use only."
       (let* ((key-id (match-string 1 string))
             (user-id (match-string 2 string))
             (entry (assoc key-id epg-user-id-alist)))
+       (condition-case nil
+           (if (eq (epg-context-protocol context) 'CMS)
+               (setq user-id (epg-dn-from-string user-id))
+             (setq user-id (epg--decode-coding-string user-id 'utf-8)))
+         (error))
        (if entry
            (setcdr entry user-id)
          (setq epg-user-id-alist (cons (cons key-id user-id)
@@ -1315,12 +1322,10 @@ This function is for internal use only."
         'verify
         (cons (epg-make-signature status key-id)
               (epg-context-result-for context 'verify)))
-       (if (eq (epg-context-protocol context) 'CMS)
-           (condition-case nil
-               (setq user-id (epg-dn-from-string user-id))
-             (error)))
        (condition-case nil
-           (setq user-id (epg--decode-coding-string user-id 'utf-8))
+           (if (eq (epg-context-protocol context) 'CMS)
+               (setq user-id (epg-dn-from-string user-id))
+             (setq user-id (epg--decode-coding-string user-id 'utf-8)))
          (error))
        (if entry
            (setcdr entry user-id)
@@ -1580,6 +1585,11 @@ This function is for internal use only."
       (let* ((key-id (match-string 1 string))
             (user-id (match-string 2 string))
             (entry (assoc key-id epg-user-id-alist)))
+       (condition-case nil
+           (if (eq (epg-context-protocol context) 'CMS)
+               (setq user-id (epg-dn-from-string user-id))
+             (setq user-id (epg--decode-coding-string user-id 'utf-8)))
+         (error))
        (if entry
            (setcdr entry user-id)
          (setq epg-user-id-alist (cons (cons key-id user-id)
@@ -1661,7 +1671,6 @@ This function is for internal use only."
                      (unless (eq (epg-context-protocol context) 'CMS)
                        '("--fixed-list-mode"))
                      (if name (list name))))
-       (coding-system-for-read 'binary)
        keys string field index)
     (with-temp-buffer
       (apply #'call-process
@@ -1705,7 +1714,7 @@ If MODE is t or 'secret, only secret keyring should be searched.
 Otherwise, only public keyring should be searched and the key
 signatures should be included."
   (let ((lines (epg--list-keys-1 context name mode))
-       keys cert pointer pointer-1 user-id-string)
+       keys cert pointer pointer-1)
     (while lines
       (cond
        ((member (aref (car lines) 0) '("pub" "sec" "crt" "crs"))
@@ -1725,22 +1734,17 @@ signatures should be included."
         (cons (epg--make-sub-key-1 (car lines))
               (epg-key-sub-key-list (car keys)))))
        ((equal (aref (car lines) 0) "uid")
-       (setq user-id-string (if cert
-                                (condition-case nil
-                                    (epg-dn-from-string (aref (car lines) 9))
-                                  (error (aref (car lines) 9)))
-                              (aref (car lines) 9)))
-       (condition-case nil
-           (setq user-id-string (epg--decode-coding-string user-id-string
-                                                           'utf-8))
-         (error))
        (epg-key-set-user-id-list
         (car keys)
         (cons (epg-make-user-id
                (if (aref (car lines) 1)
                    (cdr (assq (string-to-char (aref (car lines) 1))
                               epg-key-validity-alist)))
-               user-id-string)
+               (if cert
+                   (condition-case nil
+                       (epg-dn-from-string (aref (car lines) 9))
+                     (error (aref (car lines) 9)))
+                 (aref (car lines) 9)))
               (epg-key-user-id-list (car keys)))))
        ((equal (aref (car lines) 0) "fpr")
        (epg-sub-key-set-fingerprint (car (epg-key-sub-key-list (car keys)))