diff --git a/CHANGELOG.md b/CHANGELOG.md
index 221ed80a..492e5a1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ _This release is scheduled to be released on 2022-01-01._
- Replace spectron with playwright, update dependencies including electron update to v16.
- Added lithuanian language to translations.js
- Show info message if newsfeed is empty (fixes #2731)
+- Added dangerouslyDisableAutoEscaping config option for newsfeed templates (fixes #2712)
### Fixed
diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js
index 2fe340a2..0b781964 100644
--- a/modules/default/newsfeed/newsfeed.js
+++ b/modules/default/newsfeed/newsfeed.js
@@ -37,7 +37,8 @@ Module.register("newsfeed", {
endTags: [],
prohibitedWords: [],
scrollLength: 500,
- logFeedWarnings: false
+ logFeedWarnings: false,
+ dangerouslyDisableAutoEscaping: false
},
// Define required scripts.
diff --git a/modules/default/newsfeed/newsfeed.njk b/modules/default/newsfeed/newsfeed.njk
index b957ffb9..04f0ec79 100644
--- a/modules/default/newsfeed/newsfeed.njk
+++ b/modules/default/newsfeed/newsfeed.njk
@@ -1,3 +1,11 @@
+{% macro escapeText(text, dangerouslyDisableAutoEscaping=false) %}
+ {% if dangerouslyDisableAutoEscaping %}
+ {{ text | safe}}
+ {% else %}
+ {{ text }}
+ {% endif %}
+{% endmacro %}
+
{% if loaded %}
{% if config.showAsList %}
@@ -14,14 +22,14 @@
{% endif %}
- {{ item.title }}
+ {{ escapeText(item.title, config.dangerouslyDisableAutoEscaping) }}
{% if config.showDescription %}
{% if config.truncDescription %}
- {{ item.description | truncate(config.lengthDescription) }}
+ {{ escapeText(item.description | truncate(config.lengthDescription), config.dangerouslyDisableAutoEscaping) }}
{% else %}
- {{ item.description }}
+ {{ escapeText(item.description, config.dangerouslyDisableAutoEscaping) }}
{% endif %}
{% endif %}
@@ -33,7 +41,7 @@
{% if (config.showSourceTitle and sourceTitle) or config.showPublishDate %}
{% if sourceTitle and config.showSourceTitle %}
- {{ sourceTitle }}{% if config.showPublishDate %}, {% else %}: {% endif %}
+ {{ escapeText(sourceTitle, config.dangerouslyDisableAutoEscaping) }}{% if config.showPublishDate %}, {% else %}: {% endif %}
{% endif %}
{% if config.showPublishDate %}
{{ publishDate }}:
@@ -41,14 +49,14 @@
{% endif %}
- {{ title }}
+ {{ escapeText(title, config.dangerouslyDisableAutoEscaping) }}
{% if config.showDescription %}
{% if config.truncDescription %}
- {{ description | truncate(config.lengthDescription) }}
+ {{ escapeText(description | truncate(config.lengthDescription), config.dangerouslyDisableAutoEscaping) }}
{% else %}
- {{ description }}
+ {{ escapeText(description, config.dangerouslyDisableAutoEscaping) }}
{% endif %}
{% endif %}