Function: rfc2368-parse-mailto-url

rfc2368-parse-mailto-url is a byte-compiled function defined in rfc2368.el.gz.

Signature

(rfc2368-parse-mailto-url MAILTO-URL)

Documentation

Parse MAILTO-URL, and return an alist of header-name, header-value pairs.

MAILTO-URL should be a RFC 2368 (mailto) compliant url. A cons cell with a key of Body is a special case and is considered a header for this purpose. The returned alist is intended for use with the compose-mail interface. Note: make sure MAILTO-URL has been "unhtmlized" (e.g., & -> &), before calling this function.

Probably introduced at or before Emacs version 28.1.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/rfc2368.el.gz
(defun rfc2368-parse-mailto-url (mailto-url)
  "Parse MAILTO-URL, and return an alist of header-name, header-value pairs.
MAILTO-URL should be a RFC 2368 (mailto) compliant url.  A cons cell with a
key of `Body' is a special case and is considered a header for this purpose.
The returned alist is intended for use with the `compose-mail' interface.
Note: make sure MAILTO-URL has been \"unhtmlized\" (e.g., & -> &), before
calling this function."
  (let ((case-fold-search t)
	prequery query headers-alist)
    (setq mailto-url (string-replace "\n" " " mailto-url))
    (if (string-match rfc2368-mailto-regexp mailto-url)
	(progn
	  (setq prequery
		(match-string rfc2368-mailto-prequery-index mailto-url))
	  (setq query
		(match-string rfc2368-mailto-query-index mailto-url))

	  ;; build alist of header name-value pairs
	  (if (not (null query))
	      (setq headers-alist
		    (mapcar
		     (lambda (x)
		       (let* ((temp-list (split-string x "="))
			      (header-name (car temp-list))
			      (header-value (cadr temp-list)))
			 ;; return ("Header-Name" . "header-value")
			 (cons
			  (capitalize (rfc2368-unhexify-string header-name))
			  (rfc2368-unhexify-string header-value))))
		     (split-string query "&"))))

	  ;; deal with multiple 'To' recipients
	  (if prequery
	      (progn
		(setq prequery (rfc2368-unhexify-string prequery))
		(if (assoc "To" headers-alist)
		    (let* ((our-cons-cell
			    (assoc "To" headers-alist))
			   (our-cdr
			    (cdr our-cons-cell)))
		      (setcdr our-cons-cell (concat prequery ", " our-cdr)))
		  (setq headers-alist
			(cons (cons "To" prequery) headers-alist)))))

	  headers-alist)

      (error "Failed to match a mailto: url"))))