view/utils: Do not render large attachments.
authorRicardo Wurmus <rekado@elephly.net>
Fri, 15 May 2020 11:02:35 +0000 (13:02 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Fri, 15 May 2020 11:02:35 +0000 (13:02 +0200)
mumi/web/view/utils.scm

index 6f6e16a2148b862d17a0ceb8e86a0f19c69f688c..27cd2de9c51ce7ad4e574d42245d47d4e69ce42b 100644 (file)
@@ -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)))