`. Add '*' to this list to exempt all models.
EXEMPT_VIEW_PERMISSIONS = [
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
index 604069061..401cd80e2 100644
--- a/netbox/netbox/settings.py
+++ b/netbox/netbox/settings.py
@@ -92,6 +92,7 @@ DEVELOPER = getattr(configuration, 'DEVELOPER', False)
DJANGO_ADMIN_ENABLED = getattr(configuration, 'DJANGO_ADMIN_ENABLED', False)
DOCS_ROOT = getattr(configuration, 'DOCS_ROOT', os.path.join(os.path.dirname(BASE_DIR), 'docs'))
EMAIL = getattr(configuration, 'EMAIL', {})
+ESCAPE_BANNERS = getattr(configuration, 'ESCAPE_BANNERS', True)
EVENTS_PIPELINE = getattr(configuration, 'EVENTS_PIPELINE', (
'extras.events.process_event_queue',
))
diff --git a/netbox/templates/base/layout.html b/netbox/templates/base/layout.html
index 9ba6fded3..3812ab396 100644
--- a/netbox/templates/base/layout.html
+++ b/netbox/templates/base/layout.html
@@ -83,7 +83,11 @@ Blocks:
{# Top banner #}
{% if config.BANNER_TOP %}
- {% include 'inc/banner.html' with content=config.BANNER_TOP %}
+ {% if not settings.ESCAPE_BANNERS %}
+ {% include 'inc/banner.html' with content=config.BANNER_TOP %}
+ {% else %}
+ {% include 'inc/banner.html' with content=config.BANNER_TOP|escape %}
+ {% endif %}
{% endif %}
{# /Top banner #}
@@ -93,7 +97,11 @@ Blocks:
{% endif %}
{% if config.MAINTENANCE_MODE and config.BANNER_MAINTENANCE %}
- {% include 'inc/alerts/warning.html' with title="Maintenance Mode" message=config.BANNER_MAINTENANCE|safe %}
+ {% if not settings.ESCAPE_BANNERS %}
+ {% include 'inc/alerts/warning.html' with title="Maintenance Mode" message=config.BANNER_MAINTENANCE|safe %}
+ {% else %}
+ {% include 'inc/alerts/warning.html' with title="Maintenance Mode" message=config.BANNER_MAINTENANCE|escape %}
+ {% endif %}
{% endif %}
{# /Alerts #}
@@ -116,7 +124,11 @@ Blocks:
{# Bottom banner #}
{% if config.BANNER_BOTTOM %}
- {% include 'inc/banner.html' with content=config.BANNER_BOTTOM %}
+ {% if not settings.ESCAPE_BANNERS %}
+ {% include 'inc/banner.html' with content=config.BANNER_BOTTOM %}
+ {% else %}
+ {% include 'inc/banner.html' with content=config.BANNER_BOTTOM|escape %}
+ {% endif %}
{% endif %}
{# /Bottom banner #}
diff --git a/netbox/templates/login.html b/netbox/templates/login.html
index f8575e4c1..4e6267223 100644
--- a/netbox/templates/login.html
+++ b/netbox/templates/login.html
@@ -17,7 +17,11 @@
{# Login banner #}
{% if config.BANNER_LOGIN %}
- {{ config.BANNER_LOGIN|safe }}
+ {% if not settings.ESCAPE_BANNERS %}
+ {{ config.BANNER_LOGIN|safe }}
+ {% else %}
+ {{ config.BANNER_LOGIN|escape }}
+ {% endif %}
{% endif %}
diff --git a/netbox/utilities/error_handlers.py b/netbox/utilities/error_handlers.py
index 386ec6f39..4d61a0ab9 100644
--- a/netbox/utilities/error_handlers.py
+++ b/netbox/utilities/error_handlers.py
@@ -29,7 +29,7 @@ def handle_protectederror(obj_list, request, e):
# Formulate the error message
err_message = _("Unable to delete {objects}. {count} dependent objects were found: ").format(
- objects=', '.join(str(obj) for obj in obj_list),
+ objects=', '.join(escape(str(obj)) for obj in obj_list),
count=len(protected_objects) if len(protected_objects) <= 50 else _('More than 50')
)