diff --git a/templates/post_reply.html b/templates/post_reply.html
index ab0dc9da..6fba3c1e 100644
--- a/templates/post_reply.html
+++ b/templates/post_reply.html
@@ -35,7 +35,7 @@
{% if config.show_filename and post.filename %}
,
{% if post.filename|length > config.max_filename_display %}
- {{ post.filename|truncate(config.max_filename_display)|bidi_cleanup }}
+ {{ post.filename|truncate(config.max_filename_display)|e|bidi_cleanup }}
{% else %}
{{ post.filename|e|bidi_cleanup }}
{% endif %}
diff --git a/templates/post_thread.html b/templates/post_thread.html
index cd8ba74a..252e6f11 100644
--- a/templates/post_thread.html
+++ b/templates/post_thread.html
@@ -24,7 +24,7 @@
{% if config.show_filename and post.filename %}
,
{% if post.filename|length > config.max_filename_display %}
- {{ post.filename|truncate(config.max_filename_display)|bidi_cleanup }}
+ {{ post.filename|truncate(config.max_filename_display)|e|bidi_cleanup }}
{% else %}
{{ post.filename|e|bidi_cleanup }}
{% endif %}