Skip to content

Commit 853cdd7

Browse files
committed
Add option to disable warning on user uploaded attachments
1 parent 65f780b commit 853cdd7

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/Controller/AttachmentFileController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function htmlSandbox(Attachment $attachment, AttachmentsSettings $attachm
6565
$response = $this->render('attachments/html_sandbox.html.twig', [
6666
'attachment' => $attachment,
6767
'content' => $attachmentContent,
68+
'show_warning' => $attachmentsSettings->showHTMLAttachmentWarning,
6869
]);
6970

7071
//Set an CSP that allows to run inline scripts, styles and images from external ressources, but does not allow any connections or others.

src/Settings/SystemSettings/AttachmentsSettings.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,11 @@ class AttachmentsSettings
6565
envVar: "bool:ATTACHMENT_SHOW_HTML_FILES", envVarMode: EnvVarMode::OVERWRITE
6666
)]
6767
public bool $showHTMLAttachments = false;
68+
69+
#[SettingsParameter(
70+
label: new TM("settings.system.attachments.showHTMLAttachmentWarning"),
71+
description: new TM("settings.system.attachments.showHTMLAttachmentWarning.help"),
72+
envVar: "bool:ATTACHMENT_SHOW_HTML_WARNING", envVarMode: EnvVarMode::OVERWRITE
73+
)]
74+
public bool $showHTMLAttachmentWarning = true;
6875
}

templates/attachments/html_sandbox.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
<div class="wrapper">
5252

53+
{% if show_warning %}
5354
<header>
5455
<header class="warning-bar">
5556
<b>⚠️ {% trans%}attachment.sandbox.warning{% endtrans %}</b>
@@ -62,6 +63,7 @@
6263
</small>
6364
</header>
6465
</header>
66+
{% endif %}
6567

6668
<iframe referrerpolicy="no-referrer" class="content-frame"
6769
{# When changing this sandbox, also change the sandbox CSP in the controller #}

translations/messages.en.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13001,6 +13001,18 @@ Buerklin-API Authentication server:
1300113001
<target>WARNING: You are viewing an user uploaded attachment. This is untrusted content. Proceed with care.</target>
1300213002
</segment>
1300313003
</unit>
13004+
<unit id="Ax9Tml2" name="settings.system.attachments.showHTMLAttachmentWarning">
13005+
<segment state="translated">
13006+
<source>settings.system.attachments.showHTMLAttachmentWarning</source>
13007+
<target>Show warning when opening user uploaded attachments</target>
13008+
</segment>
13009+
</unit>
13010+
<unit id="Bx3Nkp8" name="settings.system.attachments.showHTMLAttachmentWarning.help">
13011+
<segment state="translated">
13012+
<source>settings.system.attachments.showHTMLAttachmentWarning.help</source>
13013+
<target>When enabled, a warning banner is shown when viewing user uploaded HTML attachments in the sandbox, reminding the user that the content is untrusted.</target>
13014+
</segment>
13015+
</unit>
1300413016
<unit id="bRcdnJK" name="attachment.sandbox.back_to_partdb">
1300513017
<segment state="translated">
1300613018
<source>attachment.sandbox.back_to_partdb</source>

0 commit comments

Comments
 (0)