diff options
| author | Stefan Monnier | 2018-10-19 22:31:35 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-10-19 22:31:35 -0400 |
| commit | d684f5d5bc33249038e779a4b2009fd0761f09d5 (patch) | |
| tree | be952f8d06000b43800efb69a4d2cc38d6eb6765 | |
| parent | 32e411943d3f1d1546bfcb1aad8c4d4cd28857d6 (diff) | |
| download | emacs-d684f5d5bc33249038e779a4b2009fd0761f09d5.tar.gz emacs-d684f5d5bc33249038e779a4b2009fd0761f09d5.zip | |
* lisp/mail/smtpmail.el: (smtpmail-send-queued-mail): Avoid 'load'
(smtpmail-send-it): Send metadata directly to the
files without bothering to write it into a temp buffer.
| -rw-r--r-- | lisp/mail/smtpmail.el | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 8bc3cc78d95..9b045b25584 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -150,7 +150,8 @@ and sent with `smtpmail-send-queued-mail'." | |||
| 150 | :group 'smtpmail) | 150 | :group 'smtpmail) |
| 151 | 151 | ||
| 152 | (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" | 152 | (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" |
| 153 | "Directory where `smtpmail.el' stores queued mail." | 153 | "Directory where `smtpmail.el' stores queued mail. |
| 154 | This directory should not be writable by other users." | ||
| 154 | :type 'directory | 155 | :type 'directory |
| 155 | :group 'smtpmail) | 156 | :group 'smtpmail) |
| 156 | 157 | ||
| @@ -360,9 +361,7 @@ for `smtpmail-try-auth-method'.") | |||
| 360 | smtpmail-queue-dir)) | 361 | smtpmail-queue-dir)) |
| 361 | (file-data (convert-standard-filename file-data)) | 362 | (file-data (convert-standard-filename file-data)) |
| 362 | (file-elisp (concat file-data ".el")) | 363 | (file-elisp (concat file-data ".el")) |
| 363 | (buffer-data (create-file-buffer file-data)) | 364 | (buffer-data (create-file-buffer file-data))) |
| 364 | (buffer-elisp (create-file-buffer file-elisp)) | ||
| 365 | (buffer-scratch "*queue-mail*")) | ||
| 366 | (unless (file-exists-p smtpmail-queue-dir) | 365 | (unless (file-exists-p smtpmail-queue-dir) |
| 367 | (make-directory smtpmail-queue-dir t)) | 366 | (make-directory smtpmail-queue-dir t)) |
| 368 | (with-current-buffer buffer-data | 367 | (with-current-buffer buffer-data |
| @@ -377,22 +376,16 @@ for `smtpmail-try-auth-method'.") | |||
| 377 | nil t) | 376 | nil t) |
| 378 | (insert-buffer-substring tembuf) | 377 | (insert-buffer-substring tembuf) |
| 379 | (write-file file-data) | 378 | (write-file file-data) |
| 380 | (set-buffer buffer-elisp) | 379 | (write-region |
| 381 | (erase-buffer) | 380 | (concat "(setq smtpmail-recipient-address-list '" |
| 382 | (insert (concat | ||
| 383 | "(setq smtpmail-recipient-address-list '" | ||
| 384 | (prin1-to-string smtpmail-recipient-address-list) | 381 | (prin1-to-string smtpmail-recipient-address-list) |
| 385 | ")\n")) | 382 | ")\n") |
| 386 | (write-file file-elisp) | 383 | nil file-elisp nil 'silent) |
| 387 | (set-buffer (generate-new-buffer buffer-scratch)) | 384 | (write-region (concat file-data "\n") nil |
| 388 | (insert (concat file-data "\n")) | 385 | (expand-file-name smtpmail-queue-index-file |
| 389 | (append-to-file (point-min) | 386 | smtpmail-queue-dir) |
| 390 | (point-max) | 387 | t 'silent)) |
| 391 | (expand-file-name smtpmail-queue-index-file | 388 | (kill-buffer buffer-data)))) |
| 392 | smtpmail-queue-dir))) | ||
| 393 | (kill-buffer buffer-scratch) | ||
| 394 | (kill-buffer buffer-data) | ||
| 395 | (kill-buffer buffer-elisp)))) | ||
| 396 | (kill-buffer tembuf) | 389 | (kill-buffer tembuf) |
| 397 | (if (bufferp errbuf) | 390 | (if (bufferp errbuf) |
| 398 | (kill-buffer errbuf))))) | 391 | (kill-buffer errbuf))))) |
| @@ -412,7 +405,21 @@ for `smtpmail-try-auth-method'.") | |||
| 412 | (goto-char (point-min)) | 405 | (goto-char (point-min)) |
| 413 | (while (not (eobp)) | 406 | (while (not (eobp)) |
| 414 | (setq file-msg (buffer-substring (point) (line-end-position))) | 407 | (setq file-msg (buffer-substring (point) (line-end-position))) |
| 415 | (load file-msg) | 408 | ;; FIXME: Avoid `load' which can execute arbitrary code and is hence |
| 409 | ;; a source of security holes. Better read the file and extract the | ||
| 410 | ;; data "by hand". | ||
| 411 | ;;(load file-msg) | ||
| 412 | (with-temp-buffer | ||
| 413 | (insert-file-contents (concat file-msg ".el")) | ||
| 414 | (goto-char (point-min)) | ||
| 415 | (pcase (read (current-buffer)) | ||
| 416 | (`(setq smtpmail-recipient-address-list ',v) | ||
| 417 | (skip-chars-forward " \n\t") | ||
| 418 | (unless (eobp) (message "Ignoring trailing text in %S" | ||
| 419 | (concat file-msg ".el"))) | ||
| 420 | (setq smtpmail-recipient-address-list v)) | ||
| 421 | (sexp (error "Unexpected code in %S: %S" | ||
| 422 | (concat file-msg ".el") sexp)))) | ||
| 416 | ;; Insert the message literally: it is already encoded as per | 423 | ;; Insert the message literally: it is already encoded as per |
| 417 | ;; the MIME headers, and code conversions might guess the | 424 | ;; the MIME headers, and code conversions might guess the |
| 418 | ;; encoding wrongly. | 425 | ;; encoding wrongly. |