1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

Treat passed strings as raw-text when percent-escaping in epg

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).
This commit is contained in:
Robert Pluim 2019-12-09 18:41:59 +01:00
parent 7a498af10a
commit d57bb0c323

View 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)