From dfa996c747257e8c97d75bfff4e365656a6e83b0 Mon Sep 17 00:00:00 2001 From: teranisi Date: Sun, 12 Dec 2004 14:09:09 +0000 Subject: [PATCH] (rfc2368-unhexify-string): Rewrite (%0D%0A -> \n). (rfc2368-parse-mailto-url): Remove newline. --- utils/ChangeLog | 5 +++++ utils/rfc2368.el | 30 +++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/utils/ChangeLog b/utils/ChangeLog index 3068934..86bf92b 100644 --- a/utils/ChangeLog +++ b/utils/ChangeLog @@ -1,3 +1,8 @@ +2004-12-12 Yuuichi Teranishi + + * rfc2368.el (rfc2368-unhexify-string): Rewrite (%0D%0A -> \n). + (rfc2368-parse-mailto-url): Remove newline. + 2004-12-12 Hiroya Murata * rfc2368.el (rfc2368-unhexify-string): Treat `A' - `F' and not diff --git a/utils/rfc2368.el b/utils/rfc2368.el index 7edf428..abca6ed 100644 --- a/utils/rfc2368.el +++ b/utils/rfc2368.el @@ -78,14 +78,19 @@ (defun rfc2368-unhexify-string (string) "Unhexify STRING -- e.g. 'hello%20there' -> 'hello there'." - (with-temp-buffer - (insert string) - (goto-char (point-min)) - (while (re-search-forward "%\\([0-9A-F][0-9A-F]\\)" nil t) - (replace-match (string (string-to-number (match-string 1) - 16)) - nil nil)) - (buffer-string))) + (let ((start 0) + (buf)) + (while (string-match "+\\|%\\(0D%0A\\|\\([0-9a-fA-F][0-9a-fA-F]\\)\\)" + string start) + (push (substring string start (match-beginning 0)) buf) + (push (cond + ((match-beginning 2) + (vector (string-to-number (match-string 2 string) 16))) + ((match-beginning 1) "\n") + (t " ")) + buf) + (setq start (match-end 0))) + (apply 'concat (nreverse (cons (substring string start) buf))))) (defun rfc2368-parse-mailto-url (mailto-url) "Parse MAILTO-URL, and return an alist of header-name, header-value pairs. @@ -96,7 +101,14 @@ Note: make sure MAILTO-URL has been 'unhtmlized' (e.g. & -> &), before calling this function." (let ((case-fold-search t) prequery query headers-alist) - + ;; Remove newline + (setq mailto-url + (with-temp-buffer + (insert mailto-url) + (goto-char (point-min)) + (while (re-search-forward "\n" nil t) + (replace-match "")) + (buffer-string))) (if (string-match rfc2368-mailto-regexp mailto-url) (progn -- 1.7.10.4