diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2020-05-15 13:02:35 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2020-05-15 13:02:35 +0200 |
commit | 99b5470f7fdec2cf923ad055e85bc1a65cd53aa7 (patch) | |
tree | 15c4ddf6f5c47d625cc3c72e648291cc1594f5b6 | |
parent | 931a7c3359185c674aecddb3ff44f716a9f47feb (diff) |
view/utils: Do not render large attachments.
-rw-r--r-- | mumi/web/view/utils.scm | 13 |
1 files 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))) |