From 358ed2559af215b139866aa9402bb7b85b603a31 Mon Sep 17 00:00:00 2001 From: cahrens Date: Fri, 11 Mar 2016 18:04:56 -0500 Subject: [PATCH] Fix improper escaping. --- cms/static/js/views/content_group_details.js | 6 ++-- .../js/content-group-details.underscore | 25 ++++++++------- .../js/group-configuration-details.underscore | 31 ++++++++++--------- .../cohort_management.html | 3 +- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/cms/static/js/views/content_group_details.js b/cms/static/js/views/content_group_details.js index 4357b04aaa..4b6ed76820 100644 --- a/cms/static/js/views/content_group_details.js +++ b/cms/static/js/views/content_group_details.js @@ -75,18 +75,18 @@ define([ }, getOutlineAnchorMessage: function () { - var message = gettext( + var message = _.escape(gettext( /* Translators: 'outlineAnchor' is an anchor pointing to the course outline page. */ 'This content group is not in use. Add a content group to any unit from the %(outlineAnchor)s.' - ), + )), anchor = str.sprintf( '%(text)s', { url: this.model.collection.parents[0].outlineUrl, - text: gettext('Course Outline') + text: _.escape(gettext('Course Outline')) } ); diff --git a/cms/templates/js/content-group-details.underscore b/cms/templates/js/content-group-details.underscore index b5bc267411..670fab89fb 100644 --- a/cms/templates/js/content-group-details.underscore +++ b/cms/templates/js/content-group-details.underscore @@ -3,7 +3,7 @@

- <%= name %> + <%- name %>

@@ -11,28 +11,28 @@
    <% if (!_.isUndefined(id)) { %>
  1. <%= gettext('ID') %>: <%= id %><%- gettext('ID') %>: <%- id %>
  2. <% } %> <% if (!showContentGroupUsages) { %>
  3. - <%= usageCountMessage %> + <%- usageCountMessage %>
  4. <% } %>
@@ -41,17 +41,18 @@ <% if (showContentGroupUsages) { %>
<% if (!_.isEmpty(usage)) { %> -

<%= gettext('This content group is used in:') %>

+

<%- gettext('This content group is used in:') %>

    <% _.each(usage, function(unit) { %>
  1. -

    ><%= unit.label %>

    +

    ><%- unit.label %>

  2. <% }) %>
<% } else { %>

- <%= outlineAnchorMessage %> + + <%= outlineAnchorMessage %>

<% } %>
diff --git a/cms/templates/js/group-configuration-details.underscore b/cms/templates/js/group-configuration-details.underscore index c26afc56e4..4f5bc0374b 100644 --- a/cms/templates/js/group-configuration-details.underscore +++ b/cms/templates/js/group-configuration-details.underscore @@ -3,7 +3,7 @@

- <%= name %> + <%- name %>

@@ -11,20 +11,20 @@
    <% if (!_.isUndefined(id)) { %>
  1. <%= gettext('ID') %>: <%= id %><%- gettext('ID') %>: <%- id %>
  2. <% } %> <% if (showGroups) { %>
  3. - <%= description %> + <%- description %>
  4. <% } else { %>
  5. - <%= groupsCountMessage %> + <%- groupsCountMessage %>
  6. - <%= usageCountMessage %> + <%- usageCountMessage %>
  7. <% } %>
@@ -34,23 +34,23 @@
    <% groups.each(function(group, groupIndex) { %>
  1. - <%= group.get('name') %> - <%= allocation %>% + <%- group.get('name') %> + <%- allocation %>%
  2. <% }) %>
<% } %> @@ -58,11 +58,11 @@ <% if(showGroups) { %>
<% if (!_.isEmpty(usage)) { %> -

<%= gettext('This Group Configuration is used in:') %>

+

<%- gettext('This Group Configuration is used in:') %>

    <% _.each(usage, function(unit) { %>
  1. -

    ><%= unit.label %>

    +

    ><%- unit.label %>

    <% if (unit.validation) { %>

    <% if (unit.validation.type === 'warning') { %> @@ -71,7 +71,7 @@ <% } %> - <%= unit.validation.text %> + <%- unit.validation.text %>

    <% } %> @@ -80,6 +80,7 @@
<% } else { %>

+ <%= outlineAnchorMessage %>

<% } %> diff --git a/lms/templates/instructor/instructor_dashboard_2/cohort_management.html b/lms/templates/instructor/instructor_dashboard_2/cohort_management.html index 71d5fe0dfc..81fe4c4221 100644 --- a/lms/templates/instructor/instructor_dashboard_2/cohort_management.html +++ b/lms/templates/instructor/instructor_dashboard_2/cohort_management.html @@ -2,6 +2,7 @@ <%namespace name='static' file='../../static_content.html'/> <%! from django.utils.translation import ugettext as _ +from openedx.core.djangolib.js_utils import js_escaped_string from courseware.courses import get_studio_url from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition %> @@ -27,7 +28,7 @@ from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_ % for content_group in content_groups: { id: ${content_group.id}, - name: "${content_group.name | h}", + name: "${content_group.name | n, js_escaped_string}", user_partition_id: cohortUserPartitionId }, % endfor