diff --git a/lms/djangoapps/shoppingcart/tests/test_views.py b/lms/djangoapps/shoppingcart/tests/test_views.py index 0a5cd7bf99..2dbe338c78 100644 --- a/lms/djangoapps/shoppingcart/tests/test_views.py +++ b/lms/djangoapps/shoppingcart/tests/test_views.py @@ -1824,11 +1824,11 @@ class RegistrationCodeRedemptionCourseEnrollment(SharedModuleStoreTestCase): RegistrationCodeRedemption.objects.filter(registration_code__code=registration_code) response = self.client.get(redeem_url) self.assertEquals(len(RegistrationCodeRedemption.objects.filter(registration_code__code=registration_code)), 1) - self.assertIn("You've clicked a link for an enrollment code that has already been used.", response.content) + self.assertIn("You've clicked a link for an enrollment code that has already been used.", response.content) #now check that the registration code has already been redeemed response = self.client.post(redeem_url) - self.assertIn("You've clicked a link for an enrollment code that has already been used.", response.content) + self.assertIn("You've clicked a link for an enrollment code that has already been used.", response.content) #now check the response of the dashboard page dashboard_url = reverse('dashboard') diff --git a/lms/envs/common.py b/lms/envs/common.py index f4815f3c50..e221bbc212 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2305,6 +2305,7 @@ INSTALLED_APPS = [ # edx-drf-extensions 'csrf.apps.CsrfAppConfig', # Enables frontend apps to retrieve CSRF tokens. + 'xss_utils' ] ######################### CSRF ######################################### diff --git a/lms/templates/admin/base_site.html b/lms/templates/admin/base_site.html index d050919de3..4b36642f6b 100644 --- a/lms/templates/admin/base_site.html +++ b/lms/templates/admin/base_site.html @@ -7,13 +7,13 @@ {% block nav-global %}{% endblock %} {% block userlinks %} {% if site_url %} - {% trans 'View site' %} / + {% trans 'View site' as tmsg%}{{tmsg|force_escape}} / {% endif %} {% if user.is_active and user.is_staff %} {% url 'django-admindocs-docroot' as docsroot %} {% if docsroot %} - {% trans 'Documentation' %} / + {% trans 'Documentation' as tmsg%}{{tmsg|force_escape}} / {% endif %} {% endif %} - {% trans 'Log out' %} + {% trans 'Log out' as tmsg%}{{tmsg|force_escape}} {% endblock %} diff --git a/lms/templates/admin/user_api/accounts/cancel_retirement_action.html b/lms/templates/admin/user_api/accounts/cancel_retirement_action.html index e90a6dc555..07be7dc3e1 100644 --- a/lms/templates/admin/user_api/accounts/cancel_retirement_action.html +++ b/lms/templates/admin/user_api/accounts/cancel_retirement_action.html @@ -10,12 +10,14 @@ {% if form.non_field_errors|length > 0 %}
- {% trans "Please correct the errors below." %} + {% trans "Please correct the errors below." as tmsg %}{{tmsg|force_escape}}
{{ form.non_field_errors }} {% endif %} + {% filter force_escape %} {% blocktrans with username=retirement.user.username %}Are you sure you want to cancel retirement for user "{{ username }}"? {% endblocktrans %} + {% endfilter %}- {% blocktrans trimmed %} - If you are not redirected within 5 seconds, click here to go to the home page. + {% blocktrans trimmed asvar signout_msg1 %} + If you are not redirected within 5 seconds, {start_anchor}click here to go to the home page{end_anchor}. {% endblocktrans %} + {% interpolate_html signout_msg1 start_anchor=''|safe end_anchor=''|safe %}
- ${_('Required fields are noted by bold text and an asterisk (*).')} + ${Text(_('Required fields are noted by {strong_start}bold text and an asterisk (*){strong_end}.')).format( + strong_start=HTML(''), + strong_end=HTML('')),}
% if course_id and enrollment_action: - - + + % endif- ${_("You have re-enabled forum notification emails from {platform_name}. " - "You may {dashboard_link_start}return to your dashboard{link_end}.").format( + ${Text(_("You have re-enabled forum notification emails from {platform_name}. " + "You may {dashboard_link_start}return to your dashboard{link_end}.")).format( platform_name=settings.PLATFORM_NAME, - dashboard_link_start="".format(reverse('dashboard')), - link_end="",)} + dashboard_link_start=HTML("").format(reverse('dashboard')), + link_end=HTML(""),)}
diff --git a/lms/templates/shoppingcart/registration_code_redemption.html b/lms/templates/shoppingcart/registration_code_redemption.html index 6ea7a9efb1..a9a6d42a20 100644 --- a/lms/templates/shoppingcart/registration_code_redemption.html +++ b/lms/templates/shoppingcart/registration_code_redemption.html @@ -1,5 +1,7 @@ +<%page expression_filter="h"/> <%! from django.utils.translation import ugettext as _ +from openedx.core.djangolib.markup import HTML, Text from django.urls import reverse from openedx.core.lib.courses import course_image_url %> @@ -20,34 +22,34 @@ from openedx.core.lib.courses import course_image_url% if reg_code_already_redeemed: - ${_( + ${Text(_( "You've clicked a link for an enrollment code that has already " "been used. Check your {link_start}course dashboard{link_end} " "to see if you're enrolled in the course, or contact your " "company's administrator." - ).format( - link_start=u''.format(url=reverse('dashboard')), - link_end='', + )).format( + link_start=HTML(u'').format(url=reverse('dashboard')), + link_end=HTML(''), )} % elif redemption_success: ${_( @@ -55,15 +57,15 @@ from openedx.core.lib.courses import course_image_url "This course has now been added to your dashboard." ).format( course_name=course.display_name, - ) | h} + )} % elif registered_for_course: - ${_( + ${Text(_( "You're already enrolled for this course. " "Visit your {link_start}dashboard{link_end} to see the course." - ).format( - link_start=u''.format(url=reverse('dashboard')), - link_end='', - )} + )).format( + link_start=HTML(u'').format(url=reverse('dashboard')), + link_end=HTML(''), + )} % elif redeem_code_error: ${_( "There was an error processing your redeem code.")} % else: @@ -75,7 +77,7 @@ from openedx.core.lib.courses import course_image_url ).format( course_name=course.display_name, site_name=site_name, - ) | h} + )} % endif
${_('Welcome {name}').format(name=extauth_id)}
${Text(_('{start_li}Welcome{end_li} {name}')).format( + start_li=HTML(''), + end_li=HTML(''), + name=extauth_id)}
${_('Enter a public username:')}
@@ -127,17 +133,17 @@ import calendar