- (base64-decode-region (point-min)
- ;; Some mailers insert whitespace
- ;; junk at the end which
- ;; base64-decode-region dislikes.
- (save-excursion
- (goto-char (point-max))
- (skip-chars-backward "\n\t ")
- (delete-region (point) (point-max))
- (point))))
+ (base64-decode-region
+ (point-min)
+ ;; Some mailers insert whitespace
+ ;; junk at the end which
+ ;; base64-decode-region dislikes.
+ ;; Also remove possible junk which could
+ ;; have been added by mailing list software.
+ (save-excursion
+ (goto-char (point-min))
+ (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))))