From 99b5470f7fdec2cf923ad055e85bc1a65cd53aa7 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 15 May 2020 13:02:35 +0200 Subject: view/utils: Do not render large attachments. --- mumi/web/view/utils.scm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mumi/web/view/utils.scm b/mumi/web/view/utils.scm index 6f6e16a..27cd2de 100644 --- a/mumi/web/view/utils.scm +++ b/mumi/web/view/utils.scm @@ -234,15 +234,20 @@ BUG-NUM), even when it is a multipart message." (cut assoc-ref <> 'type)) content-type (assoc-ref content-type 'type))) - (binary-attachment? (and attachment? - (member (assoc-ref content-type 'type) - '(application image video)))) + (hide-attachment? (and attachment? + (or (member (assoc-ref content-type 'type) + '(application image video)) + (and=> (assoc-ref headers 'content-disposition) + (lambda (disposition) + (and=> (assoc-ref disposition 'size) + (lambda (size) + (> size 5000)))))))) (attachment-name (or (and=> (assoc-ref headers 'content-disposition) (cut assoc-ref <> 'filename)) "file"))) (cond - ((or html? binary-attachment?) + ((or html? hide-attachment?) `(div (@ (class "attachment")) "Attachment: " (a (@ (href ,(attachment-url))) ,attachment-name))) -- cgit v1.2.3