From 9a3ff05192c0e4a5a6fe8d3abe4d1b1d0e796bbc Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 3 Oct 2016 21:27:06 +0300 Subject: [PATCH] mu4e: handle overflow for plaintext-ratio-heuristic Handle overflow when multiplying mu4e-view-html-plaintext-ratio-heuristic by most-positive-fixnum. --- mu4e/mu4e-message.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mu4e/mu4e-message.el b/mu4e/mu4e-message.el index edad3129..c3e98cd5 100644 --- a/mu4e/mu4e-message.el +++ b/mu4e/mu4e-message.el @@ -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