(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string user-id 'utf-8))
+ (setq user-id (epg--decode-coding-string
+ (epg--decode-percent-escape user-id)
+ 'utf-8))
(error))
(if entry
(setcdr entry user-id)
(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)))
+ (setq user-id (epg--decode-coding-string
+ (epg--decode-percent-escape user-id)
+ 'utf-8)))
(error))
(if entry
(setcdr entry user-id)
(user-id (match-string 2 string))
(entry (assoc key-id epg-user-id-alist)))
(condition-case nil
- (setq user-id (epg--decode-coding-string user-id 'utf-8))
+ (setq user-id (epg--decode-coding-string
+ (epg--decode-percent-escape user-id)
+ 'utf-8))
(error))
(if entry
(setcdr entry user-id)
(epg-context-result-for context 'error))))
(epg-reset context)))
+(defun epg--decode-percent-escape (string)
+ (let ((index 0))
+ (while (string-match "%\\(\\(%\\)\\|\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)"
+ string index)
+ (if (match-beginning 2)
+ (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))
+ t t string)
+ index (- (match-end 0) 2))))
+ string))
+
(defun epg--decode-hexstring (string)
(let ((index 0))
(while (eq index (string-match "[0-9A-Fa-f][0-9A-Fa-f]" string index))
- (setq string (replace-match "\\\\x\\&" t nil string)
+ (setq string (replace-match (string (string-to-number
+ (match-string 0 string) 16))
+ t t string)
index (+ index 4)))
- (car (read-from-string (concat "\"" string "\"")))))
+ string))
(defun epg--decode-quotedstring (string)
(let ((index 0))
(while (string-match "\\\\\\(\\([,=+<>#;\\\"]\\)\\|\
-\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\|\\(.\\)\\)"
+\\([0-9A-Fa-f][0-9A-Fa-f]\\)\\)"
string index)
(if (match-beginning 2)
- (setq string (replace-match "\\2" t nil string)
- index (1+ index))
+ (setq string (replace-match "\\2" t t string)
+ index (1- (match-end 0)))
(if (match-beginning 3)
- (setq string (replace-match "\\\\x\\3" t nil string)
- index (+ index 4))
- (setq string (replace-match "\\\\\\\\\\4" t nil string)
- index (+ index 3)))))
- (car (read-from-string (concat "\"" string "\"")))))
+ (setq string (replace-match (string (string-to-number
+ (match-string 0 string) 16))
+ t t string)
+ index (- (match-end 0) 2)))))
+ string))
(defun epg-dn-from-string (string)
"Parse STRING as LADPv3 Distinguished Names (RFC2253).