diff options
| author | Christophe Troestler | 2019-06-05 15:37:04 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-06-22 12:25:19 +0300 |
| commit | 248a82e31f84d8dedfd875562bea522336d663e6 (patch) | |
| tree | be16a555b7c022277871118463a96e7e89a0d270 | |
| parent | 4daccefa85e37ded2e6b399c82f92f23d129c7f8 (diff) | |
| download | emacs-248a82e31f84d8dedfd875562bea522336d663e6.tar.gz emacs-248a82e31f84d8dedfd875562bea522336d663e6.zip | |
epg: Use unibyte string to decode percent escapes
* lisp/epg.el (epg--status-USERID_HINT, epg--status-*SIG)
(epg--status-IMPORTED): Call epg--decode-percent-escape-as-utf-8.
(epg--decode-percent-escape): Convert STRING to unibyte.
(epg--decode-percent-escape-as-utf-8): New function. (Bug#36098)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/epg.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/epg.el b/lisp/epg.el index e8bdd1536ff..a8b5a408a89 100644 --- a/lisp/epg.el +++ b/lisp/epg.el | |||
| @@ -776,9 +776,7 @@ callback data (if any)." | |||
| 776 | (user-id (match-string 2 string)) | 776 | (user-id (match-string 2 string)) |
| 777 | (entry (assoc key-id epg-user-id-alist))) | 777 | (entry (assoc key-id epg-user-id-alist))) |
| 778 | (condition-case nil | 778 | (condition-case nil |
| 779 | (setq user-id (decode-coding-string | 779 | (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)) |
| 780 | (epg--decode-percent-escape user-id) | ||
| 781 | 'utf-8)) | ||
| 782 | (error)) | 780 | (error)) |
| 783 | (if entry | 781 | (if entry |
| 784 | (setcdr entry user-id) | 782 | (setcdr entry user-id) |
| @@ -905,9 +903,7 @@ callback data (if any)." | |||
| 905 | (condition-case nil | 903 | (condition-case nil |
| 906 | (if (eq (epg-context-protocol context) 'CMS) | 904 | (if (eq (epg-context-protocol context) 'CMS) |
| 907 | (setq user-id (epg-dn-from-string user-id)) | 905 | (setq user-id (epg-dn-from-string user-id)) |
| 908 | (setq user-id (decode-coding-string | 906 | (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))) |
| 909 | (epg--decode-percent-escape user-id) | ||
| 910 | 'utf-8))) | ||
| 911 | (error)) | 907 | (error)) |
| 912 | (if entry | 908 | (if entry |
| 913 | (setcdr entry user-id) | 909 | (setcdr entry user-id) |
| @@ -1183,9 +1179,7 @@ callback data (if any)." | |||
| 1183 | (user-id (match-string 2 string)) | 1179 | (user-id (match-string 2 string)) |
| 1184 | (entry (assoc key-id epg-user-id-alist))) | 1180 | (entry (assoc key-id epg-user-id-alist))) |
| 1185 | (condition-case nil | 1181 | (condition-case nil |
| 1186 | (setq user-id (decode-coding-string | 1182 | (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)) |
| 1187 | (epg--decode-percent-escape user-id) | ||
| 1188 | 'utf-8)) | ||
| 1189 | (error)) | 1183 | (error)) |
| 1190 | (if entry | 1184 | (if entry |
| 1191 | (setcdr entry user-id) | 1185 | (setcdr entry user-id) |
| @@ -2026,6 +2020,7 @@ If you are unsure, use synchronous version of this function | |||
| 2026 | (epg-reset context))) | 2020 | (epg-reset context))) |
| 2027 | 2021 | ||
| 2028 | (defun epg--decode-percent-escape (string) | 2022 | (defun epg--decode-percent-escape (string) |
| 2023 | (setq string (string-to-unibyte string)) | ||
| 2029 | (let ((index 0)) | 2024 | (let ((index 0)) |
| 2030 | (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)" | 2025 | (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)" |
| 2031 | string index) | 2026 | string index) |
| @@ -2033,11 +2028,15 @@ If you are unsure, use synchronous version of this function | |||
| 2033 | (setq string (replace-match "%" t t string) | 2028 | (setq string (replace-match "%" t t string) |
| 2034 | index (1- (match-end 0))) | 2029 | index (1- (match-end 0))) |
| 2035 | (setq string (replace-match | 2030 | (setq string (replace-match |
| 2036 | (string (string-to-number (match-string 3 string) 16)) | 2031 | (byte-to-string |
| 2032 | (string-to-number (match-string 3 string) 16)) | ||
| 2037 | t t string) | 2033 | t t string) |
| 2038 | index (- (match-end 0) 2)))) | 2034 | index (- (match-end 0) 2)))) |
| 2039 | string)) | 2035 | string)) |
| 2040 | 2036 | ||
| 2037 | (defun epg--decode-percent-escape-as-utf-8 (string) | ||
| 2038 | (decode-coding-string (epg--decode-percent-escape string) 'utf-8)) | ||
| 2039 | |||
| 2041 | (defun epg--decode-hexstring (string) | 2040 | (defun epg--decode-hexstring (string) |
| 2042 | (let ((index 0)) | 2041 | (let ((index 0)) |
| 2043 | (while (eq index (string-match "[0-9A-Fa-f][0-9A-Fa-f]" string index)) | 2042 | (while (eq index (string-match "[0-9A-Fa-f][0-9A-Fa-f]" string index)) |