]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Rmail-MIME size estimations
authorEli Zaretskii <eliz@gnu.org>
Tue, 20 Apr 2021 14:58:18 +0000 (17:58 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 20 Apr 2021 14:58:18 +0000 (17:58 +0300)
The quoted-printable estimation was obviously wrong: the size becomes
smaller when decoded, not larger...
* lisp/mail/rmailmm.el (rmail-mime-set-bulk-data): Fix estimations
of decoded MIME attachment.

lisp/mail/rmailmm.el

index e08500a18985c2b80e80c8ddd8eb9d3a7f9419c8..1295a086f5248d119d8d3b2703780c7f1526dd24 100644 (file)
@@ -784,9 +784,11 @@ directly."
           (let ((encoding (rmail-mime-entity-transfer-encoding entity)))
             (setq size (- (aref body 1) (aref body 0)))
             (cond ((string= encoding "base64")
-                   (setq size (/ (* size 3) 4)))
+                    ;; https://en.wikipedia.org/wiki/Base64#MIME
+                   (setq size (max (* (- size 814) 0.73) 100)))
                   ((string= encoding "quoted-printable")
-                   (setq size (/ (* size 7) 3)))))))
+                    ;; Assume most of the text is ASCII...
+                   (setq size (/ (* size 5) 7)))))))
 
     (cond
      ((string-match "text/html" content-type)