diff options
| author | Miles Bader | 2008-04-26 04:29:42 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-04-26 04:29:42 +0000 |
| commit | 58a67d68bfc2eafe0cd029aa33693228f21f4e51 (patch) | |
| tree | 009923ba472fb824796a3cd59f91925c17ee8c5b | |
| parent | 1ea193a2b6414ac6186de0840e5b734c7d82a810 (diff) | |
| download | emacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.tar.gz emacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.zip | |
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1128
| -rw-r--r-- | lisp/gnus/ChangeLog | 25 | ||||
| -rw-r--r-- | lisp/gnus/auth-source.el | 45 | ||||
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 52 | ||||
| -rw-r--r-- | lisp/gnus/mail-source.el | 28 | ||||
| -rw-r--r-- | lisp/gnus/mm-encode.el | 13 |
5 files changed, 121 insertions, 42 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 0282e4151e7..d5f72bc4846 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,9 +1,34 @@ | |||
| 1 | 2008-04-25 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * mail-source.el: Load auth-source.el. | ||
| 4 | (mail-source-bind): Add comments. Call auth-source-user-or-password to | ||
| 5 | get user name or password, if auth-sources is set up. | ||
| 6 | |||
| 7 | * gnus-registry.el (gnus-registry-split-strategy): New variable for | ||
| 8 | strategy of splitting with parent. | ||
| 9 | (gnus-registry-split-fancy-with-parent) | ||
| 10 | (gnus-registry-post-process-groups): Use it and fix prior | ||
| 11 | bug (returning a list as the split result). | ||
| 12 | |||
| 13 | * auth-source.el (auth-sources): Remove server parameter. | ||
| 14 | (auth-source-pick, auth-source-user-or-password) | ||
| 15 | (auth-source-user-or-password-imap) | ||
| 16 | (auth-source-user-or-password-pop3, auth-source-user-or-password-ssh) | ||
| 17 | (auth-source-user-or-password-sftp) | ||
| 18 | (auth-source-user-or-password-smtp): Remove server parameter. | ||
| 19 | |||
| 1 | 2008-04-25 Juanma Barranquero <lekktu@gmail.com> | 20 | 2008-04-25 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 21 | ||
| 3 | * smime.el (smime-sign-region, smime-encrypt-region) | 22 | * smime.el (smime-sign-region, smime-encrypt-region) |
| 4 | (smime-decrypt-region): | 23 | (smime-decrypt-region): |
| 5 | Remove redundant calls to `generate-new-buffer-name'. | 24 | Remove redundant calls to `generate-new-buffer-name'. |
| 6 | 25 | ||
| 26 | 2008-04-24 Luca Capello <luca@pca.it> (tiny change) | ||
| 27 | |||
| 28 | * mm-encode.el (mm-safer-encoding): Add optional argument `type'. | ||
| 29 | Don't use QP for message/rfc822. | ||
| 30 | (mm-content-transfer-encoding): Pass `type' to mm-safer-encoding. | ||
| 31 | |||
| 7 | 2008-04-24 Stefan Monnier <monnier@iro.umontreal.ca> | 32 | 2008-04-24 Stefan Monnier <monnier@iro.umontreal.ca> |
| 8 | 33 | ||
| 9 | * sieve-manage.el (sieve-string-bytes): Remove. | 34 | * sieve-manage.el (sieve-string-bytes): Remove. |
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el index 9883eb64acc..a2a4dcf24cc 100644 --- a/lisp/gnus/auth-source.el +++ b/lisp/gnus/auth-source.el | |||
| @@ -86,11 +86,6 @@ Each entry is the authentication type with optional properties." | |||
| 86 | (list :tag "Source definition" | 86 | (list :tag "Source definition" |
| 87 | (const :format "" :value :source) | 87 | (const :format "" :value :source) |
| 88 | (string :tag "Authentication Source") | 88 | (string :tag "Authentication Source") |
| 89 | (const :format "" :value :server) | ||
| 90 | (choice :tag "Server (logical name) choice" | ||
| 91 | (const :tag "Any" t) | ||
| 92 | (regexp :tag "Server regular expression (TODO)") | ||
| 93 | (const :tag "Fallback" nil)) | ||
| 94 | (const :format "" :value :host) | 89 | (const :format "" :value :host) |
| 95 | (choice :tag "Host (machine) choice" | 90 | (choice :tag "Host (machine) choice" |
| 96 | (const :tag "Any" t) | 91 | (const :tag "Any" t) |
| @@ -118,20 +113,16 @@ Each entry is the authentication type with optional properties." | |||
| 118 | ;; (auth-source-user-or-password-imap "password" "imap.myhost.com") | 113 | ;; (auth-source-user-or-password-imap "password" "imap.myhost.com") |
| 119 | ;; (auth-source-protocol-defaults 'imap) | 114 | ;; (auth-source-protocol-defaults 'imap) |
| 120 | 115 | ||
| 121 | (defun auth-source-pick (server host protocol &optional fallback) | 116 | (defun auth-source-pick (host protocol &optional fallback) |
| 122 | "Parse `auth-sources' for SERVER, HOST, and PROTOCOL matches. | 117 | "Parse `auth-sources' for HOST, and PROTOCOL matches. |
| 123 | 118 | ||
| 124 | Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK t." | 119 | Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t." |
| 125 | (interactive "sHost: \nsProtocol: \n") ;for testing | 120 | (interactive "sHost: \nsProtocol: \n") ;for testing |
| 126 | (let (choices) | 121 | (let (choices) |
| 127 | (dolist (choice auth-sources) | 122 | (dolist (choice auth-sources) |
| 128 | (let ((s (plist-get choice :server)) | 123 | (let ((h (plist-get choice :host)) |
| 129 | (h (plist-get choice :host)) | ||
| 130 | (p (plist-get choice :protocol))) | 124 | (p (plist-get choice :protocol))) |
| 131 | (when (and | 125 | (when (and |
| 132 | (or (equal t s) | ||
| 133 | (and (stringp s) (string-match s server)) | ||
| 134 | (and fallback (equal s nil))) | ||
| 135 | (or (equal t h) | 126 | (or (equal t h) |
| 136 | (and (stringp h) (string-match h host)) | 127 | (and (stringp h) (string-match h host)) |
| 137 | (and fallback (equal h nil))) | 128 | (and fallback (equal h nil))) |
| @@ -142,12 +133,12 @@ Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK | |||
| 142 | (if choices | 133 | (if choices |
| 143 | choices | 134 | choices |
| 144 | (unless fallback | 135 | (unless fallback |
| 145 | (auth-source-pick server host protocol t))))) | 136 | (auth-source-pick host protocol t))))) |
| 146 | 137 | ||
| 147 | (defun auth-source-user-or-password (mode server host protocol) | 138 | (defun auth-source-user-or-password (mode host protocol) |
| 148 | "Find user or password (from the string MODE) matching SERVER, HOST, and PROTOCOL." | 139 | "Find user or password (from the string MODE) matching HOST and PROTOCOL." |
| 149 | (let (found) | 140 | (let (found) |
| 150 | (dolist (choice (auth-source-pick server host protocol)) | 141 | (dolist (choice (auth-source-pick host protocol)) |
| 151 | (setq found (netrc-machine-user-or-password | 142 | (setq found (netrc-machine-user-or-password |
| 152 | mode | 143 | mode |
| 153 | (plist-get choice :source) | 144 | (plist-get choice :source) |
| @@ -161,20 +152,20 @@ Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK | |||
| 161 | "Return a list of default ports and names for PROTOCOL." | 152 | "Return a list of default ports and names for PROTOCOL." |
| 162 | (cdr-safe (assoc protocol auth-source-protocols))) | 153 | (cdr-safe (assoc protocol auth-source-protocols))) |
| 163 | 154 | ||
| 164 | (defun auth-source-user-or-password-imap (mode server host) | 155 | (defun auth-source-user-or-password-imap (mode host) |
| 165 | (auth-source-user-or-password mode server host 'imap)) | 156 | (auth-source-user-or-password mode host 'imap)) |
| 166 | 157 | ||
| 167 | (defun auth-source-user-or-password-pop3 (mode server host) | 158 | (defun auth-source-user-or-password-pop3 (mode host) |
| 168 | (auth-source-user-or-password mode server host 'pop3)) | 159 | (auth-source-user-or-password mode host 'pop3)) |
| 169 | 160 | ||
| 170 | (defun auth-source-user-or-password-ssh (mode server host) | 161 | (defun auth-source-user-or-password-ssh (mode host) |
| 171 | (auth-source-user-or-password mode server host 'ssh)) | 162 | (auth-source-user-or-password mode host 'ssh)) |
| 172 | 163 | ||
| 173 | (defun auth-source-user-or-password-sftp (mode server host) | 164 | (defun auth-source-user-or-password-sftp (mode host) |
| 174 | (auth-source-user-or-password mode server host 'sftp)) | 165 | (auth-source-user-or-password mode host 'sftp)) |
| 175 | 166 | ||
| 176 | (defun auth-source-user-or-password-smtp (mode server host) | 167 | (defun auth-source-user-or-password-smtp (mode host) |
| 177 | (auth-source-user-or-password mode server host 'smtp)) | 168 | (auth-source-user-or-password mode host 'smtp)) |
| 178 | 169 | ||
| 179 | (provide 'auth-source) | 170 | (provide 'auth-source) |
| 180 | 171 | ||
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index fd08d4d1e39..93ee0efce85 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -161,6 +161,17 @@ way." | |||
| 161 | (const :tag "Track by subject (Subject: header)" subject) | 161 | (const :tag "Track by subject (Subject: header)" subject) |
| 162 | (const :tag "Track by sender (From: header)" sender))) | 162 | (const :tag "Track by sender (From: header)" sender))) |
| 163 | 163 | ||
| 164 | (defcustom gnus-registry-split-strategy nil | ||
| 165 | "Whether the registry should track extra data about a message. | ||
| 166 | The Subject and Sender (From:) headers are currently tracked this | ||
| 167 | way." | ||
| 168 | :group 'gnus-registry | ||
| 169 | :type | ||
| 170 | '(choice :tag "Tracking choices" | ||
| 171 | (const :tag "Only use single choices, discard multiple matches" nil) | ||
| 172 | (const :tag "Majority of matches wins" majority) | ||
| 173 | (const :tag "First found wins" first))) | ||
| 174 | |||
| 164 | (defcustom gnus-registry-entry-caching t | 175 | (defcustom gnus-registry-entry-caching t |
| 165 | "Whether the registry should cache extra information." | 176 | "Whether the registry should cache extra information." |
| 166 | :group 'gnus-registry | 177 | :group 'gnus-registry |
| @@ -486,7 +497,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 486 | nnmail-split-fancy-with-parent-ignore-groups | 497 | nnmail-split-fancy-with-parent-ignore-groups |
| 487 | (list nnmail-split-fancy-with-parent-ignore-groups))) | 498 | (list nnmail-split-fancy-with-parent-ignore-groups))) |
| 488 | (log-agent "gnus-registry-split-fancy-with-parent") | 499 | (log-agent "gnus-registry-split-fancy-with-parent") |
| 489 | found) | 500 | found found-full) |
| 490 | 501 | ||
| 491 | ;; this is a big if-else statement. it uses | 502 | ;; this is a big if-else statement. it uses |
| 492 | ;; gnus-registry-post-process-groups to filter the results after | 503 | ;; gnus-registry-post-process-groups to filter the results after |
| @@ -507,9 +518,10 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 507 | log-agent reference refstr group) | 518 | log-agent reference refstr group) |
| 508 | (push group found)))) | 519 | (push group found)))) |
| 509 | ;; filter the found groups and return them | 520 | ;; filter the found groups and return them |
| 521 | ;; the found groups are the full groups | ||
| 510 | (setq found (gnus-registry-post-process-groups | 522 | (setq found (gnus-registry-post-process-groups |
| 511 | "references" refstr found))) | 523 | "references" refstr found found))) |
| 512 | 524 | ||
| 513 | ;; else: there were no matches, now try the extra tracking by sender | 525 | ;; else: there were no matches, now try the extra tracking by sender |
| 514 | ((and (gnus-registry-track-sender-p) | 526 | ((and (gnus-registry-track-sender-p) |
| 515 | sender) | 527 | sender) |
| @@ -522,6 +534,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 522 | (equal sender this-sender)) | 534 | (equal sender this-sender)) |
| 523 | (let ((groups (gnus-registry-fetch-groups key))) | 535 | (let ((groups (gnus-registry-fetch-groups key))) |
| 524 | (dolist (group groups) | 536 | (dolist (group groups) |
| 537 | (push group found-full) | ||
| 525 | (setq found (append (list group) (delete group found))))) | 538 | (setq found (append (list group) (delete group found))))) |
| 526 | (push key matches) | 539 | (push key matches) |
| 527 | (gnus-message | 540 | (gnus-message |
| @@ -531,7 +544,9 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 531 | log-agent sender found matches)))) | 544 | log-agent sender found matches)))) |
| 532 | gnus-registry-hashtb) | 545 | gnus-registry-hashtb) |
| 533 | ;; filter the found groups and return them | 546 | ;; filter the found groups and return them |
| 534 | (setq found (gnus-registry-post-process-groups "sender" sender found))) | 547 | ;; the found groups are NOT the full groups |
| 548 | (setq found (gnus-registry-post-process-groups | ||
| 549 | "sender" sender found found-full))) | ||
| 535 | 550 | ||
| 536 | ;; else: there were no matches, now try the extra tracking by subject | 551 | ;; else: there were no matches, now try the extra tracking by subject |
| 537 | ((and (gnus-registry-track-subject-p) | 552 | ((and (gnus-registry-track-subject-p) |
| @@ -546,6 +561,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 546 | (equal subject this-subject)) | 561 | (equal subject this-subject)) |
| 547 | (let ((groups (gnus-registry-fetch-groups key))) | 562 | (let ((groups (gnus-registry-fetch-groups key))) |
| 548 | (dolist (group groups) | 563 | (dolist (group groups) |
| 564 | (push group found-full) | ||
| 549 | (setq found (append (list group) (delete group found))))) | 565 | (setq found (append (list group) (delete group found))))) |
| 550 | (push key matches) | 566 | (push key matches) |
| 551 | (gnus-message | 567 | (gnus-message |
| @@ -555,10 +571,13 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 555 | log-agent subject found matches)))) | 571 | log-agent subject found matches)))) |
| 556 | gnus-registry-hashtb) | 572 | gnus-registry-hashtb) |
| 557 | ;; filter the found groups and return them | 573 | ;; filter the found groups and return them |
| 574 | ;; the found groups are NOT the full groups | ||
| 558 | (setq found (gnus-registry-post-process-groups | 575 | (setq found (gnus-registry-post-process-groups |
| 559 | "subject" subject found)))))) | 576 | "subject" subject found found-full)))) |
| 577 | ;; after the (cond) we extract the actual value safely | ||
| 578 | (car-safe found))) | ||
| 560 | 579 | ||
| 561 | (defun gnus-registry-post-process-groups (mode key groups) | 580 | (defun gnus-registry-post-process-groups (mode key groups groups-full) |
| 562 | "Modifies GROUPS found by MODE for KEY to determine which ones to follow. | 581 | "Modifies GROUPS found by MODE for KEY to determine which ones to follow. |
| 563 | 582 | ||
| 564 | MODE can be 'subject' or 'sender' for example. The KEY is the | 583 | MODE can be 'subject' or 'sender' for example. The KEY is the |
| @@ -572,9 +591,28 @@ This is not possible if gnus-registry-use-long-group-names is | |||
| 572 | false. Foreign methods are not supported so they are rejected. | 591 | false. Foreign methods are not supported so they are rejected. |
| 573 | 592 | ||
| 574 | Reduces the list to a single group, or complains if that's not | 593 | Reduces the list to a single group, or complains if that's not |
| 575 | possible." | 594 | possible. Uses `gnus-registry-split-strategy' and GROUPS-FULL if |
| 595 | necessary." | ||
| 576 | (let ((log-agent "gnus-registry-post-process-group") | 596 | (let ((log-agent "gnus-registry-post-process-group") |
| 577 | out) | 597 | out) |
| 598 | |||
| 599 | ;; the strategy can be 'first, 'majority, or nil | ||
| 600 | (when (eq gnus-registry-split-strategy 'first) | ||
| 601 | (when groups | ||
| 602 | (setq groups (list (car-safe groups))))) | ||
| 603 | |||
| 604 | (when (eq gnus-registry-split-strategy 'majority) | ||
| 605 | (let ((freq (make-hash-table | ||
| 606 | :size 256 | ||
| 607 | :test 'equal))) | ||
| 608 | (mapc (lambda(x) (puthash x (1+ (gethash x freq 0)) freq)) groups-full) | ||
| 609 | (setq groups (list (car-safe | ||
| 610 | (sort | ||
| 611 | groups | ||
| 612 | (lambda (a b) | ||
| 613 | (> (gethash a freq 0) | ||
| 614 | (gethash b freq 0))))))))) | ||
| 615 | |||
| 578 | (if gnus-registry-use-long-group-names | 616 | (if gnus-registry-use-long-group-names |
| 579 | (dolist (group groups) | 617 | (dolist (group groups) |
| 580 | (let ((m1 (gnus-find-method-for-group group)) | 618 | (let ((m1 (gnus-find-method-for-group group)) |
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el index a26f885894d..d8633b7a6a4 100644 --- a/lisp/gnus/mail-source.el +++ b/lisp/gnus/mail-source.el | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | (require 'cl) | 36 | (require 'cl) |
| 37 | (require 'imap)) | 37 | (require 'imap)) |
| 38 | (eval-and-compile | 38 | (eval-and-compile |
| 39 | (autoload 'auth-source-user-or-password "auth-source") | ||
| 39 | (autoload 'pop3-movemail "pop3") | 40 | (autoload 'pop3-movemail "pop3") |
| 40 | (autoload 'pop3-get-message-count "pop3") | 41 | (autoload 'pop3-get-message-count "pop3") |
| 41 | (autoload 'nnheader-cancel-timer "nnheader")) | 42 | (autoload 'nnheader-cancel-timer "nnheader")) |
| @@ -44,7 +45,6 @@ | |||
| 44 | 45 | ||
| 45 | (defvar display-time-mail-function) | 46 | (defvar display-time-mail-function) |
| 46 | 47 | ||
| 47 | |||
| 48 | (defgroup mail-source nil | 48 | (defgroup mail-source nil |
| 49 | "The mail-fetching library." | 49 | "The mail-fetching library." |
| 50 | :version "21.1" | 50 | :version "21.1" |
| @@ -420,6 +420,8 @@ All keywords that can be used must be listed here.")) | |||
| 420 | "Strip the leading colon off the KEYWORD." | 420 | "Strip the leading colon off the KEYWORD." |
| 421 | (intern (substring (symbol-name keyword) 1)))) | 421 | (intern (substring (symbol-name keyword) 1)))) |
| 422 | 422 | ||
| 423 | ;; generate a list of variable names paired with nil values | ||
| 424 | ;; suitable for usage in a `let' form | ||
| 423 | (eval-and-compile | 425 | (eval-and-compile |
| 424 | (defun mail-source-bind-1 (type) | 426 | (defun mail-source-bind-1 (type) |
| 425 | (let* ((defaults (cdr (assq type mail-source-keyword-map))) | 427 | (let* ((defaults (cdr (assq type mail-source-keyword-map))) |
| @@ -438,14 +440,30 @@ At run time, the mail source specifier SOURCE will be inspected, | |||
| 438 | and the variables will be set according to it. Variables not | 440 | and the variables will be set according to it. Variables not |
| 439 | specified will be given default values. | 441 | specified will be given default values. |
| 440 | 442 | ||
| 443 | The user and password will be loaded from the auth-source values | ||
| 444 | if those are available. They override the original user and | ||
| 445 | password in a second `let' form. | ||
| 446 | |||
| 441 | After this is done, BODY will be executed in the scope | 447 | After this is done, BODY will be executed in the scope |
| 442 | of the `let' form. | 448 | of the second `let' form. |
| 443 | 449 | ||
| 444 | The variables bound and their default values are described by | 450 | The variables bound and their default values are described by |
| 445 | the `mail-source-keyword-map' variable." | 451 | the `mail-source-keyword-map' variable." |
| 446 | `(let ,(mail-source-bind-1 (car type-source)) | 452 | `(let* ,(mail-source-bind-1 (car type-source)) |
| 447 | (mail-source-set-1 ,(cadr type-source)) | 453 | (mail-source-set-1 ,(cadr type-source)) |
| 448 | ,@body)) | 454 | (let ((user (or |
| 455 | (auth-source-user-or-password | ||
| 456 | "login" | ||
| 457 | server ; this is "host" in auth-sources | ||
| 458 | ',(car type-source)) | ||
| 459 | user)) | ||
| 460 | (password (or | ||
| 461 | (auth-source-user-or-password | ||
| 462 | "password" | ||
| 463 | server ; this is "host" in auth-sources | ||
| 464 | ',(car type-source)) | ||
| 465 | password))) | ||
| 466 | ,@body))) | ||
| 449 | 467 | ||
| 450 | (put 'mail-source-bind 'lisp-indent-function 1) | 468 | (put 'mail-source-bind 'lisp-indent-function 1) |
| 451 | (put 'mail-source-bind 'edebug-form-spec '(sexp body)) | 469 | (put 'mail-source-bind 'edebug-form-spec '(sexp body)) |
| @@ -455,6 +473,8 @@ the `mail-source-keyword-map' variable." | |||
| 455 | (defaults (cdr (assq type mail-source-keyword-map))) | 473 | (defaults (cdr (assq type mail-source-keyword-map))) |
| 456 | default value keyword) | 474 | default value keyword) |
| 457 | (while (setq default (pop defaults)) | 475 | (while (setq default (pop defaults)) |
| 476 | ;; for each default :SYMBOL, set SYMBOL to the plist value for :SYMBOL | ||
| 477 | ;; using `mail-source-value' to evaluate the plist value | ||
| 458 | (set (mail-source-strip-keyword (setq keyword (car default))) | 478 | (set (mail-source-strip-keyword (setq keyword (car default))) |
| 459 | (if (setq value (plist-get source keyword)) | 479 | (if (setq value (plist-get source keyword)) |
| 460 | (mail-source-value value) | 480 | (mail-source-value value) |
diff --git a/lisp/gnus/mm-encode.el b/lisp/gnus/mm-encode.el index 2597a5d5d97..3dce8d1920f 100644 --- a/lisp/gnus/mm-encode.el +++ b/lisp/gnus/mm-encode.el | |||
| @@ -96,14 +96,19 @@ This variable should never be set directly, but bound before a call to | |||
| 96 | "application/octet-stream" | 96 | "application/octet-stream" |
| 97 | (mailcap-extension-to-mime (match-string 0 file)))) | 97 | (mailcap-extension-to-mime (match-string 0 file)))) |
| 98 | 98 | ||
| 99 | (defun mm-safer-encoding (encoding) | 99 | (defun mm-safer-encoding (encoding &optional type) |
| 100 | "Return an encoding similar to ENCODING but safer than it." | 100 | "Return an encoding similar to ENCODING but safer than it." |
| 101 | (cond | 101 | (cond |
| 102 | ((eq encoding '7bit) '7bit) ;; 7bit is considered safe. | 102 | ((eq encoding '7bit) '7bit) ;; 7bit is considered safe. |
| 103 | ((memq encoding '(8bit quoted-printable)) 'quoted-printable) | 103 | ((memq encoding '(8bit quoted-printable)) |
| 104 | ;; According to RFC2046, 5.2.1, RFC822 Subtype, "quoted-printable" is not | ||
| 105 | ;; a valid encoding for message/rfc822: | ||
| 106 | ;; No encoding other than "7bit", "8bit", or "binary" is permitted for the | ||
| 107 | ;; body of a "message/rfc822" entity. | ||
| 108 | (if (string= type "message/rfc822") '8bit 'quoted-printable)) | ||
| 104 | ;; The remaining encodings are binary and base64 (and perhaps some | 109 | ;; The remaining encodings are binary and base64 (and perhaps some |
| 105 | ;; non-standard ones), which are both turned into base64. | 110 | ;; non-standard ones), which are both turned into base64. |
| 106 | (t 'base64))) | 111 | (t (if (string= type "message/rfc822") 'binary 'base64)))) |
| 107 | 112 | ||
| 108 | (defun mm-encode-content-transfer-encoding (encoding &optional type) | 113 | (defun mm-encode-content-transfer-encoding (encoding &optional type) |
| 109 | "Encode the current buffer with ENCODING for MIME type TYPE. | 114 | "Encode the current buffer with ENCODING for MIME type TYPE. |
| @@ -178,7 +183,7 @@ The encoding used is returned." | |||
| 178 | (mm-qp-or-base64) | 183 | (mm-qp-or-base64) |
| 179 | (cadr (car rules))))) | 184 | (cadr (car rules))))) |
| 180 | (if mm-use-ultra-safe-encoding | 185 | (if mm-use-ultra-safe-encoding |
| 181 | (mm-safer-encoding encoding) | 186 | (mm-safer-encoding encoding type) |
| 182 | encoding)))) | 187 | encoding)))) |
| 183 | (pop rules))))) | 188 | (pop rules))))) |
| 184 | 189 | ||