Synch with Gnus.
[elisp/gnus.git-] / lisp / mm-bodies.el
index 74870e2..f90f74c 100644 (file)
@@ -108,7 +108,7 @@ If no encoding was done, nil is returned."
   "Do Content-Transfer-Encoding and return the encoding of the current buffer."
   (let ((bits (mm-body-7-or-8)))
     (cond
-     ((eq bits '7bit)
+     ((and (not mm-use-ultra-safe-encoding) (eq bits '7bit))
       bits)
      ((and (not mm-use-ultra-safe-encoding)
           (or (eq t (cdr message-posting-charset))
@@ -168,12 +168,13 @@ If no encoding was done, nil is returned."
             ;; have been added by mailing list software.
             (save-excursion
               (goto-char (point-min))
-              (if (re-search-forward "^[\t ]*$" nil t)
-                  (delete-region (point) (point-max))
-                (goto-char (point-max)))
-              (skip-chars-backward "\n\t ")
-              (delete-region (point) (point-max))
-              (point))))
+              (while (re-search-forward "^[\t ]*\r?\n" nil t)
+                (delete-region (match-beginning 0) (match-end 0)))
+              (goto-char (point-max))
+              (when (re-search-backward "^[A-Za-z0-9+/]+=*[\t ]*$" nil t)
+                (forward-line)
+                (delete-region (point) (point-max)))
+              (point-max))))
           ((memq encoding '(7bit 8bit binary))
            ;; Do nothing.
            )
@@ -230,13 +231,13 @@ The characters in CHARSET should then be decoded."
 
 (defun mm-decode-string (string charset)
   "Decode STRING with CHARSET."
-  (if (stringp charset)
-      (setq charset (intern (downcase charset))))
-  (if (or (not charset) 
-         (eq 'gnus-all mail-parse-ignored-charsets)
-         (memq 'gnus-all mail-parse-ignored-charsets)
-         (memq charset mail-parse-ignored-charsets))
-      (setq charset mail-parse-charset))
+  (when (stringp charset)
+    (setq charset (intern (downcase charset))))
+  (when (or (not charset) 
+           (eq 'gnus-all mail-parse-ignored-charsets)
+           (memq 'gnus-all mail-parse-ignored-charsets)
+           (memq charset mail-parse-ignored-charsets))
+    (setq charset mail-parse-charset))
   (or
    (when (featurep 'mule)
      (let ((mule-charset (mm-charset-to-coding-system charset)))