From bf066909a710adb935188287528303550b8a5611 Mon Sep 17 00:00:00 2001 From: luelista Date: Thu, 16 Jul 2026 13:14:37 +0200 Subject: [PATCH] Remove more usages of |safe (#6363) * Replace |safe with |escapejson where appropriate * Use JSON encoding for data-replace-with-qr --- src/pretix/base/payment.py | 4 ++-- .../control/templates/pretixcontrol/auth/login_2fa.html | 4 ++-- .../control/templates/pretixcontrol/order/cancel.html | 3 ++- .../control/templates/pretixcontrol/order/index.html | 4 ++-- .../pretixcontrol/organizers/device_connect.html | 3 ++- .../templates/pretixcontrol/user/2fa_confirm_totp.html | 8 ++------ .../pretixcontrol/user/2fa_confirm_webauthn.html | 5 ++--- .../control/templates/pretixcontrol/user/reauth.html | 3 ++- src/pretix/control/views/orders.py | 4 ++-- src/pretix/helpers/escapejson.py | 2 +- .../stripe/static/pretixplugins/stripe/pretix-stripe.js | 4 ++-- .../stripe/templates/pretixplugins/stripe/sca.html | 2 +- src/pretix/static/pretixcontrol/js/ui/main.js | 8 -------- 13 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/pretix/base/payment.py b/src/pretix/base/payment.py index 9c463eb94..c8047bbd5 100644 --- a/src/pretix/base/payment.py +++ b/src/pretix/base/payment.py @@ -936,7 +936,7 @@ class BasePaymentProvider: """ Will be called if the *event administrator* views the details of a payment. - It should return HTML code containing information regarding the current payment + It should return a SafeString containing HTML code, with information regarding the current payment status and, if applicable, next steps. The default implementation returns an empty string. @@ -961,7 +961,7 @@ class BasePaymentProvider: """ Will be called if the *event administrator* views the details of a refund. - It should return HTML code containing information regarding the current refund + It should return a SafeString containing HTML code, with information regarding the current refund status and, if applicable, next steps. The default implementation returns an empty string. diff --git a/src/pretix/control/templates/pretixcontrol/auth/login_2fa.html b/src/pretix/control/templates/pretixcontrol/auth/login_2fa.html index 760769b3a..d5370a45a 100644 --- a/src/pretix/control/templates/pretixcontrol/auth/login_2fa.html +++ b/src/pretix/control/templates/pretixcontrol/auth/login_2fa.html @@ -3,6 +3,7 @@ {% load i18n %} {% load static %} {% load compress %} +{% load escapejson %} {% block content %}
{% csrf_token %} @@ -30,8 +31,7 @@
{% if jsondata %} {% endif %} {% compress js %} diff --git a/src/pretix/control/templates/pretixcontrol/order/cancel.html b/src/pretix/control/templates/pretixcontrol/order/cancel.html index 158cce737..f4a404042 100644 --- a/src/pretix/control/templates/pretixcontrol/order/cancel.html +++ b/src/pretix/control/templates/pretixcontrol/order/cancel.html @@ -2,6 +2,7 @@ {% load i18n %} {% load bootstrap3 %} {% load money %} +{% load wrap_in %} {% block title %} {% trans "Cancel order" %} {% endblock %} @@ -26,7 +27,7 @@ {% if form.cancellation_fee %} {% if fee %} {% with fee|money:request.event.currency as f %} -

{% blocktrans trimmed with fee=""|add:f|add:""|safe %} +

{% blocktrans trimmed with fee=f|wrap_in:"strong" %} The configured cancellation fee for a self-service cancellation would be {{ fee }} for this order, but for a cancellation performed by you, you need to set the cancellation fee here: {% endblocktrans %}

diff --git a/src/pretix/control/templates/pretixcontrol/order/index.html b/src/pretix/control/templates/pretixcontrol/order/index.html index 352877761..cdba94c04 100644 --- a/src/pretix/control/templates/pretixcontrol/order/index.html +++ b/src/pretix/control/templates/pretixcontrol/order/index.html @@ -903,7 +903,7 @@ - {{ p.html_info|safe }} + {{ p.html_info }} {% if staff_session %}

@@ -1018,7 +1018,7 @@ {% endif %} {% if r.html_info %} - {{ r.html_info|safe }} + {{ r.html_info }} {% endif %} {% if staff_session %}

diff --git a/src/pretix/control/templates/pretixcontrol/organizers/device_connect.html b/src/pretix/control/templates/pretixcontrol/organizers/device_connect.html index 63ba0d201..5f933b301 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/device_connect.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/device_connect.html @@ -2,6 +2,7 @@ {% load i18n %} {% load static %} {% load bootstrap3 %} +{% load escapejson %} {% block inner %}

{% trans "Connect to device:" %} {{ device.name }}

@@ -18,7 +19,7 @@ {% trans "Open the app that you want to connect and optionally reset it to the original state." %}
  • {% trans "Scan the following configuration code:" %}

    -
    +
    {% trans "If your app/device does not support scanning a QR code, you can also enter the following information:" %}
    {% trans "System URL:" %} {{ settings.SITE_URL }} diff --git a/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_totp.html b/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_totp.html index a25ca03cf..a0b4489f3 100644 --- a/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_totp.html +++ b/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_totp.html @@ -1,6 +1,7 @@ {% extends "pretixcontrol/base.html" %} {% load i18n %} {% load bootstrap3 %} +{% load escapejson %} {% block title %}{% trans "Add a two-factor authentication device" %}{% endblock %} {% block content %}

    {% trans "Add a two-factor authentication device" %}

    @@ -32,7 +33,7 @@
  • {% trans "Add a new account to the app by scanning the following barcode:" %} -
    +

    {% trans "Can't scan the barcode?" %} @@ -81,9 +82,4 @@

  • - {% endblock %} diff --git a/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_webauthn.html b/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_webauthn.html index 1b064b8aa..f03b03fe5 100644 --- a/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_webauthn.html +++ b/src/pretix/control/templates/pretixcontrol/user/2fa_confirm_webauthn.html @@ -3,6 +3,7 @@ {% load bootstrap3 %} {% load static %} {% load compress %} +{% load escapejson %} {% block title %}{% trans "Add a two-factor authentication device" %}{% endblock %} {% block content %}

    {% trans "Add a two-factor authentication device" %}

    @@ -26,9 +27,7 @@ {% trans "Device registration failed." %} {% compress js %} diff --git a/src/pretix/control/templates/pretixcontrol/user/reauth.html b/src/pretix/control/templates/pretixcontrol/user/reauth.html index 797e5ef58..caa61ed0a 100644 --- a/src/pretix/control/templates/pretixcontrol/user/reauth.html +++ b/src/pretix/control/templates/pretixcontrol/user/reauth.html @@ -3,6 +3,7 @@ {% load bootstrap3 %} {% load compress %} {% load static %} +{% load escapejson %} {% block content %}