]> git.eshelyaron.com Git - emacs.git/commitdiff
Treat passed strings as raw-text when percent-escaping in epg
authorRobert Pluim <rpluim@gmail.com>
Mon, 9 Dec 2019 17:41:59 +0000 (18:41 +0100)
committerRobert Pluim <rpluim@gmail.com>
Thu, 12 Dec 2019 07:28:25 +0000 (08:28 +0100)
The strings contained in gpg keys can contain UTF-8 data, but can also
use percent-escapes to encode non-ASCII chars.  When converting those
escapes, use 'raw-text' coding system rather than 'string-to-unibyte',
since the latter signals an error for non-ASCII characters.

* lisp/epg.el (epg--decode-percent-escape): Convert the passed
string to raw-text before treating percent escapes (Bug#38512).

lisp/epg.el

index 090317f4221d19e9cb2b211a996429afeb795efc..5466716e34288628a89889fe85ad7a0269b17ce6 100644 (file)
@@ -2032,7 +2032,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))
+  (setq string (encode-coding-string string 'raw-text))
   (let ((index 0))
     (while (string-match "%\\(\\(%\\)\\|\\([[:xdigit:]][[:xdigit:]]\\)\\)"
                         string index)