emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 248a82e: epg: Use unibyte string to decode percent


From: Eli Zaretskii
Subject: [Emacs-diffs] master 248a82e: epg: Use unibyte string to decode percent escapes
Date: Sat, 22 Jun 2019 05:25:53 -0400 (EDT)

branch: master
commit 248a82e31f84d8dedfd875562bea522336d663e6
Author: Christophe Troestler <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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
---
 lisp/epg.el | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lisp/epg.el b/lisp/epg.el
index e8bdd15..a8b5a40 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -776,9 +776,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 (decode-coding-string
-                          (epg--decode-percent-escape user-id)
-                          'utf-8))
+           (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))
          (error))
        (if entry
            (setcdr entry user-id)
@@ -905,9 +903,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 (decode-coding-string
-                            (epg--decode-percent-escape user-id)
-                            'utf-8)))
+             (setq user-id (epg--decode-percent-escape-as-utf-8 user-id)))
          (error))
        (if entry
            (setcdr entry user-id)
@@ -1183,9 +1179,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 (decode-coding-string
-                          (epg--decode-percent-escape user-id)
-                          'utf-8))
+           (setq user-id (epg--decode-percent-escape-as-utf-8 user-id))
          (error))
        (if entry
            (setcdr entry user-id)
@@ -2026,6 +2020,7 @@ If you are unsure, use synchronous version of this 
function
     (epg-reset context)))
 
 (defun epg--decode-percent-escape (string)
+  (setq string (string-to-unibyte string))
   (let ((index 0))
     (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)"
                         string index)
@@ -2033,11 +2028,15 @@ If you are unsure, use synchronous version of this 
function
          (setq string (replace-match "%" t t string)
                index (1- (match-end 0)))
        (setq string (replace-match
-                     (string (string-to-number (match-string 3 string) 16))
+                     (byte-to-string
+                       (string-to-number (match-string 3 string) 16))
                      t t string)
              index (- (match-end 0) 2))))
     string))
 
+(defun epg--decode-percent-escape-as-utf-8 (string)
+  (decode-coding-string (epg--decode-percent-escape string) 'utf-8))
+
 (defun epg--decode-hexstring (string)
   (let ((index 0))
     (while (eq index (string-match "[0-9A-Fa-f][0-9A-Fa-f]" string index))



reply via email to

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