diff options
author | Yuuki Harano <masm+github@masm11.me> | 2021-11-11 00:39:53 +0900 |
---|---|---|
committer | Yuuki Harano <masm+github@masm11.me> | 2021-11-11 00:39:53 +0900 |
commit | 4dd1f56f29fc598a8339a345c2f8945250600602 (patch) | |
tree | af341efedffe027e533b1bcc0dbf270532e48285 /lisp/epg.el | |
parent | 4c49ec7f865bdad1629d2f125f71f4e506b258f2 (diff) | |
parent | 810fa21d26453f898de9747ece7205dfe6de9d08 (diff) | |
download | emacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.gz emacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.bz2 emacs-4dd1f56f29fc598a8339a345c2f8945250600602.zip |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'lisp/epg.el')
-rw-r--r-- | lisp/epg.el | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/lisp/epg.el b/lisp/epg.el index 36515ef4e5f..3354eb2c1ed 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -21,10 +21,13 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. +;;; Commentary: + ;;; Code: ;;; Prelude (require 'epg-config) +(require 'rfc6068) (eval-when-compile (require 'cl-lib)) (define-error 'epg-error "GPG error") @@ -331,6 +334,7 @@ callback data (if any)." (cl-defstruct (epg-key (:constructor nil) + (:copier epg--copy-key) (:constructor epg-make-key (owner-trust)) (:predicate nil)) (owner-trust nil :read-only t) @@ -432,7 +436,11 @@ callback data (if any)." (and user-id (concat " " (if (stringp user-id) - (epg--decode-percent-escape-as-utf-8 user-id) + (if (= (length user-id) (string-bytes user-id)) + ;; This is ASCII, possibly %-encoded. + (rfc6068-unhexify-string user-id) + ;; Non-ASCII, return as is. + user-id) (epg-decode-dn user-id)))) (and (epg-signature-validity signature) (format " (trust %s)" (epg-signature-validity signature))) @@ -573,7 +581,7 @@ callback data (if any)." "--status-fd" "1" "--yes") (if (and (not (eq (epg-context-protocol context) 'CMS)) - (string-match ":" (or agent-info ""))) + (string-search ":" (or agent-info ""))) '("--use-agent")) (if (and (not (eq (epg-context-protocol context) 'CMS)) (epg-context-progress-callback context)) @@ -656,16 +664,17 @@ callback data (if any)." :sentinel #'ignore :noquery t)) (setf (epg-context-error-buffer context) (process-buffer error-process)) - (with-file-modes 448 - (setq process (make-process :name "epg" - :buffer buffer - :command (cons (epg-context-program context) - args) - :connection-type 'pipe - :coding 'raw-text - :filter #'epg--process-filter - :stderr error-process - :noquery t))) + (with-existing-directory + (with-file-modes 448 + (setq process (make-process :name "epg" + :buffer buffer + :command (cons (epg-context-program context) + args) + :connection-type 'pipe + :coding 'raw-text + :filter #'epg--process-filter + :stderr error-process + :noquery t)))) (setf (epg-context-process context) process))) (defun epg--process-filter (process input) @@ -777,7 +786,7 @@ callback data (if any)." (user-id (match-string 2 string)) (entry (assoc key-id epg-user-id-alist))) (condition-case nil - (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)) + (setq user-id (rfc6068-unhexify-string user-id)) (error)) (if entry (setcdr entry user-id) @@ -798,7 +807,7 @@ callback data (if any)." (when (and epg-key-id (string-match "\\`passphrase\\." string)) (unless (epg-context-passphrase-callback context) - (error "passphrase-callback not set")) + (error "Variable `passphrase-callback' not set")) (let (inhibit-quit passphrase passphrase-with-new-line @@ -906,7 +915,7 @@ callback data (if any)." (condition-case nil (if (eq (epg-context-protocol context) 'CMS) (setq user-id (epg-dn-from-string user-id)) - (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))) + (setq user-id (rfc6068-unhexify-string user-id))) (error)) (if entry (setcdr entry user-id) @@ -1182,7 +1191,7 @@ callback data (if any)." (user-id (match-string 2 string)) (entry (assoc key-id epg-user-id-alist))) (condition-case nil - (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)) + (setq user-id (rfc6068-unhexify-string user-id)) (error)) (if entry (setcdr entry user-id) @@ -1381,7 +1390,7 @@ NAME is either a string or a list of strings." (if (seq-find (lambda (user) (eq (epg-user-id-validity user) 'revoked)) (epg-key-user-id-list key)) - (let ((copy (copy-epg-key key))) + (let ((copy (epg--copy-key key))) (setf (epg-key-user-id-list copy) (seq-remove (lambda (user) (eq (epg-user-id-validity user) 'revoked)) @@ -2061,9 +2070,11 @@ If you are unsure, use synchronous version of this function string)) (defun epg--decode-percent-escape-as-utf-8 (string) + (declare (obsolete rfc6068-unhexify-string "28.1")) (decode-coding-string (epg--decode-percent-escape string) 'utf-8)) (defun epg--decode-hexstring (string) + (declare (obsolete rfc6068-unhexify-string "28.1")) (let ((index 0)) (while (eq index (string-match "[[:xdigit:]][[:xdigit:]]" string index)) (setq string (replace-match (string (string-to-number @@ -2114,7 +2125,7 @@ The return value is an alist mapping from types to values." value (epg--decode-quotedstring (match-string 0 string))) (if (eq index (string-match "#\\([[:xdigit:]]+\\)" string index)) (setq index (match-end 0) - value (epg--decode-hexstring (match-string 1 string))) + value (rfc6068-unhexify-string (match-string 1 string) t)) (if (eq index (string-match "\"\\([^\\\"]\\|\\\\.\\)*\"" string index)) (setq index (match-end 0) |