mu4e: handle overflow for plaintext-ratio-heuristic

Handle overflow when multiplying
mu4e-view-html-plaintext-ratio-heuristic by most-positive-fixnum.
This commit is contained in:
djcb
2016-10-03 21:27:06 +03:00
parent 82dc1aeb46
commit 9a3ff05192

View File

@ -170,6 +170,9 @@ unless PREFER-HTML is non-nil."
(setq mu4e~message-body-html nil) ;; default (setq mu4e~message-body-html nil) ;; default
(let* ((txt (mu4e-message-field msg :body-txt)) (let* ((txt (mu4e-message-field msg :body-txt))
(html (mu4e-message-field msg :body-html)) (html (mu4e-message-field msg :body-html))
(txtlen (length txt))
(txtlimit (* mu4e-view-html-plaintext-ratio-heuristic txtlen))
(txtlimit (if (>= txtlimit 0) txtlimit most-positive-fixnum)) ;; overflow
(body (body
(cond (cond
;; does it look like some text? ie., if the text part is more than ;; does it look like some text? ie., if the text part is more than
@ -177,10 +180,8 @@ unless PREFER-HTML is non-nil."
;; html part, it should't be used ;; html part, it should't be used
;; This is an heuristic to guard against 'This messages requires ;; This is an heuristic to guard against 'This messages requires
;; html' text bodies. ;; html' text bodies.
((and (> (* mu4e-view-html-plaintext-ratio-heuristic ((and (> txtlen 0)
(length txt)) (length html)) (or (> txtlimit (length html)) (not prefer-html)))
;; use html if it's prefered, unless there is no html
(or (not prefer-html) (not html)))
txt) txt)
;; otherwise, it there some html? ;; otherwise, it there some html?
(html (html