From 013373c39c1b268e74d2b647545a408cf4d17fd5 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Fri, 30 May 2008 10:06:47 +0000 Subject: [PATCH] (rfc2231-decode-encoded-string): Don't decode things that are not 2-digit hexadecimal characters that follow `%'s. --- lisp/ChangeLog | 5 +++++ lisp/rfc2231.el | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a7250a2c9..83be56e46 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-05-30 Katsumi Yamaoka + + * rfc2231.el (rfc2231-decode-encoded-string): Don't decode things that + are not 2-digit hexadecimal characters that follow `%'s. + 2008-05-29 Reiner Steib * message.el (message-bogus-recipient-p): Fix type in doc string. diff --git a/lisp/rfc2231.el b/lisp/rfc2231.el index 1dd2e43b0..523f6640d 100644 --- a/lisp/rfc2231.el +++ b/lisp/rfc2231.el @@ -214,11 +214,11 @@ These look like: (mm-with-unibyte-buffer (insert value) (goto-char (point-min)) - (while (search-forward "%" nil t) + (while (re-search-forward "%\\([0-9A-Fa-f][0-9A-Fa-f]\\)" nil t) (insert (prog1 - (string-to-number (buffer-substring (point) (+ (point) 2)) 16) - (delete-region (1- (point)) (+ (point) 2))))) + (string-to-number (match-string 1) 16) + (delete-region (match-beginning 0) (match-end 0))))) ;; Decode using the charset, if any. (if (memq coding-system '(nil ascii)) (buffer-string) -- 2.25.1