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
(let* ((txt (mu4e-message-field msg :body-txt))
(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
(cond
;; 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
;; This is an heuristic to guard against 'This messages requires
;; html' text bodies.
((and (> (* mu4e-view-html-plaintext-ratio-heuristic
(length txt)) (length html))
;; use html if it's prefered, unless there is no html
(or (not prefer-html) (not html)))
((and (> txtlen 0)
(or (> txtlimit (length html)) (not prefer-html)))
txt)
;; otherwise, it there some html?
(html