Properly escape CourseKeys and UsageKeys in html templates
[LMS-11372] [LMS-11370]
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
## -*- coding: utf-8 -*-
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%! from django.template.defaultfilters import escapejs %>
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
|
||||
<!doctype html>
|
||||
@@ -14,7 +15,7 @@
|
||||
<%block name="title"></%block> |
|
||||
% if context_course:
|
||||
<% ctx_loc = context_course.location %>
|
||||
${context_course.display_name_with_default} |
|
||||
${context_course.display_name_with_default | h} |
|
||||
% endif
|
||||
edX Studio
|
||||
</title>
|
||||
@@ -329,7 +330,7 @@
|
||||
<script type="text/javascript">
|
||||
require(['js/models/course'], function(Course) {
|
||||
window.course = new Course({
|
||||
id: "${context_course.id}",
|
||||
id: "${context_course.id | escapejs}",
|
||||
name: "${context_course.display_name_with_default | h}",
|
||||
url_name: "${context_course.location.name | h}",
|
||||
org: "${context_course.location.org | h}",
|
||||
|
||||
@@ -115,7 +115,7 @@ templates = ["basic-modal", "modal-button", "edit-xblock-modal",
|
||||
|
||||
<article class="content-primary">
|
||||
<div class="container-message wrapper-message"></div>
|
||||
<section class="wrapper-xblock level-page is-hidden studio-xblock-wrapper" data-locator="${xblock_locator}" data-course-key="${xblock_locator.course_key}">
|
||||
<section class="wrapper-xblock level-page is-hidden studio-xblock-wrapper" data-locator="${xblock_locator | h}" data-course-key="${xblock_locator.course_key | h}">
|
||||
</section>
|
||||
<div class="ui-loading">
|
||||
<p><span class="spin"><i class="icon-refresh"></i></span> <span class="copy">${_("Loading...")}</span></p>
|
||||
@@ -138,7 +138,7 @@ templates = ["basic-modal", "modal-button", "edit-xblock-modal",
|
||||
<div class="wrapper-unit-id bar-mod-content">
|
||||
<h5 class="title">${_("Location ID")}</h5>
|
||||
<p class="unit-id">
|
||||
<span class="unit-id-value" id="unit-location-id-input">${unit.location.name}</span>
|
||||
<span class="unit-id-value" id="unit-location-id-input">${unit.location.name | h}</span>
|
||||
<span class="tip"><span class="sr">Tip: </span>${_("Use this ID when you create links to this unit from other course content. You enter the ID in the URL field.")}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<%def name="online_help_token()"><% return "course_rerun" %></%def>
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%! from django.template.defaultfilters import escapejs %>
|
||||
|
||||
<%block name="title">${_("Create a Course Rerun of:")}</%block>
|
||||
<%block name="bodyclass">is-signedin view-course-create view-course-create-rerun</%block>
|
||||
@@ -13,7 +14,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var source_course_key = "${source_course_key}"
|
||||
var source_course_key = "${source_course_key | escapejs}"
|
||||
</script>
|
||||
|
||||
</%block>
|
||||
@@ -37,7 +38,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
|
||||
|
||||
<h2 class="page-header-super course-original">
|
||||
<span class="sr">${_("You are creating a re-run from:")}</span>
|
||||
<span class="course-original-title-id">${source_course_key.org} ${source_course_key.course} ${source_course_key.run}</span>
|
||||
<span class="course-original-title-id">${source_course_key.org | h} ${source_course_key.course | h} ${source_course_key.run | h}</span>
|
||||
<span class="course-original-title">${display_name}</span>
|
||||
</h2>
|
||||
</header>
|
||||
@@ -79,7 +80,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
|
||||
</li>
|
||||
<li class="field text required" id="field-organization">
|
||||
<label for="rerun-course-org">${_("Organization")}</label>
|
||||
<input class="rerun-course-org" id="rerun-course-org" type="text" name="rerun-course-org" aria-required="true" value="${source_course_key.org}" placeholder="${_('e.g. UniversityX or OrganizationX')}" />
|
||||
<input class="rerun-course-org" id="rerun-course-org" type="text" name="rerun-course-org" aria-required="true" value="${source_course_key.org | h}" placeholder="${_('e.g. UniversityX or OrganizationX')}" />
|
||||
<span class="tip">
|
||||
${_("The name of the organization sponsoring the new course. (This name is often the same as the original organization name.)")}
|
||||
<strong class="tip-note" class="tip-note">${_("Note: No spaces or special characters are allowed.")}</strong>
|
||||
@@ -90,7 +91,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
|
||||
<li class="row">
|
||||
<div class="column field text required" id="field-course-number">
|
||||
<label for="rerun-course-number">${_("Course Number")}</label>
|
||||
<input class="rerun-course-number" id="rerun-course-number" type="text" name="rerun-course-number" aria-required="true" value="${source_course_key.course}" placeholder="${_('e.g. CS101')}" />
|
||||
<input class="rerun-course-number" id="rerun-course-number" type="text" name="rerun-course-number" aria-required="true" value="${source_course_key.course | h}" placeholder="${_('e.g. CS101')}" />
|
||||
<span class="tip">
|
||||
${_("The unique number that identifies the new course within the organization. (This number is often the same as the original course number.)")}
|
||||
<strong class="tip-note" class="tip-note">${_("Note: No spaces or special characters are allowed.")}</strong>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<%!
|
||||
<%!
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.template.defaultfilters import escapejs
|
||||
%>
|
||||
<%inherit file="base.html" />
|
||||
<%def name="online_help_token()"><% return "updates" %></%def>
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
<%block name="jsextra">
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
|
||||
require(["domReady!", "jquery", "js/collections/course_update", "js/models/module_info", "js/models/course_info", "js/views/course_info_edit"],
|
||||
function(doc, $, CourseUpdateCollection, ModuleInfoModel, CourseInfoModel, CourseInfoEditView) {
|
||||
var course_updates = new CourseUpdateCollection();
|
||||
@@ -28,7 +29,7 @@ require(["domReady!", "jquery", "js/collections/course_update", "js/models/modul
|
||||
course_updates.fetch({reset: true});
|
||||
|
||||
var course_handouts = new ModuleInfoModel({
|
||||
id: '${handouts_locator}'
|
||||
id: '${handouts_locator | escapejs}'
|
||||
});
|
||||
|
||||
var editor = new CourseInfoEditView({
|
||||
|
||||
@@ -73,7 +73,7 @@ from contentstore.utils import reverse_usage_url
|
||||
<h3 class="sr">${_("Page Actions")}</h3>
|
||||
<ul>
|
||||
<li class="nav-item">
|
||||
<a href="#" class="button button-new" data-category="chapter" data-parent="${context_course.location}" data-default-name="${_('Section')}" title="${_('Click to add a new section')}">
|
||||
<a href="#" class="button button-new" data-category="chapter" data-parent="${context_course.location | h}" data-default-name="${_('Section')}" title="${_('Click to add a new section')}">
|
||||
<i class="icon-plus"></i>${_('New Section')}
|
||||
</a>
|
||||
</li>
|
||||
@@ -116,7 +116,7 @@ from contentstore.utils import reverse_usage_url
|
||||
course_locator = context_course.location
|
||||
%>
|
||||
<h2 class="sr">${_("Course Outline")}</h2>
|
||||
<article class="outline outline-complex outline-course" data-locator="${course_locator}" data-course-key="${course_locator.course_key}">
|
||||
<article class="outline outline-complex outline-course" data-locator="${course_locator | h}" data-course-key="${course_locator.course_key | h}">
|
||||
</article>
|
||||
</div>
|
||||
<div class="ui-loading">
|
||||
@@ -139,7 +139,7 @@ from contentstore.utils import reverse_usage_url
|
||||
<div class="bit external-help">
|
||||
<a href="${get_online_help_info(online_help_token())['doc_url']}" target="_blank" class="button external-help-button">${_("Learn more about the course outline")}</a>
|
||||
</div>
|
||||
|
||||
|
||||
</aside>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from xmodule.tabs import StaticTab
|
||||
from django.template.defaultfilters import escapejs
|
||||
%>
|
||||
<%block name="title">${_("Pages")}</%block>
|
||||
<%block name="bodyclass">is-signedin course view-static-pages</%block>
|
||||
@@ -24,7 +25,7 @@
|
||||
function (TabsModel, TabsEditView, xmoduleLoader) {
|
||||
xmoduleLoader.done(function () {
|
||||
var model = new TabsModel({
|
||||
id: "${context_course.location}",
|
||||
id: "${context_course.location | escapejs}",
|
||||
explicit_url: "${reverse('contentstore.views.tabs_handler', kwargs={'course_key_string': context_course.id})}"
|
||||
});
|
||||
|
||||
@@ -86,7 +87,7 @@
|
||||
%>
|
||||
|
||||
% if isinstance(tab, StaticTab):
|
||||
<li class="component ${css_class}" data-locator="${tab.locator}" data-tab-id="${tab.tab_id}"></li>
|
||||
<li class="component ${css_class}" data-locator="${tab.locator | h}" data-tab-id="${tab.tab_id | h}"></li>
|
||||
|
||||
% else:
|
||||
<li class="course-nav-item ${css_class}" data-tab-id="${tab.tab_id}">
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<aside class="content-supplementary" role="complimentary">
|
||||
<dl class="export-git-info-block">
|
||||
<dt>${_("Your course:")}</dt>
|
||||
<dd class="course_text">${context_course.id}</dd>
|
||||
<dd class="course_text">${context_course.id | h}</dd>
|
||||
<dt>${_("Course git url:")}</dt>
|
||||
<dd class="giturl_text">${context_course.giturl}</dd>
|
||||
</dl>
|
||||
|
||||
@@ -140,7 +140,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
%for course_info in sorted(in_process_course_actions, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''):
|
||||
<!-- STATE: re-run is processing -->
|
||||
%if course_info['is_in_progress']:
|
||||
<li class="wrapper-course has-status" data-course-key="${course_info['course_key']}">
|
||||
<li class="wrapper-course has-status" data-course-key="${course_info['course_key'] | h}">
|
||||
<div class="course-item course-rerun is-processing">
|
||||
<div class="course-details" href="#">
|
||||
<h3 class="course-title">${course_info['display_name']}</h3>
|
||||
@@ -178,7 +178,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
|
||||
<!-- STATE: re-run has error -->
|
||||
%if course_info['is_failed']:
|
||||
<li class="wrapper-course has-status" data-course-key="${course_info['course_key']}">
|
||||
<li class="wrapper-course has-status" data-course-key="${course_info['course_key'] | h}">
|
||||
<div class="course-item course-rerun has-error">
|
||||
<div class="course-details" href="#">
|
||||
<h3 class="course-title">${course_info['display_name']}</h3>
|
||||
@@ -229,7 +229,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
<div class="courses">
|
||||
<ul class="list-courses">
|
||||
%for course_info in sorted(courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''):
|
||||
<li class="course-item" data-course-key="${course_info['course_key']}">
|
||||
<li class="course-item" data-course-key="${course_info['course_key'] | h}">
|
||||
<a class="course-link" href="${course_info['url']}">
|
||||
<h3 class="course-title">${course_info['display_name']}</h3>
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ label = xblock.display_name or xblock.scope_ids.block_type
|
||||
|
||||
% if not is_root:
|
||||
% if is_reorderable:
|
||||
<li class="studio-xblock-wrapper is-draggable" data-locator="${xblock.location}" data-course-key="${xblock.location.course_key}">
|
||||
<li class="studio-xblock-wrapper is-draggable" data-locator="${xblock.location | h}" data-course-key="${xblock.location.course_key | h}">
|
||||
% else:
|
||||
<div class="studio-xblock-wrapper" data-locator="${xblock.location}" data-course-key="${xblock.location.course_key}">
|
||||
<div class="studio-xblock-wrapper" data-locator="${xblock.location | h}" data-course-key="${xblock.location.course_key | h}">
|
||||
% endif
|
||||
|
||||
<section class="wrapper-xblock ${section_class} ${collapsible_class}">
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<%! from django.template.defaultfilters import escapejs %>
|
||||
|
||||
% if context_course:
|
||||
<%
|
||||
locator = context_course.id
|
||||
@@ -9,7 +11,7 @@
|
||||
<script type="text/javascript">
|
||||
// if inside course, inject the course location into the JS namespace
|
||||
%if context_course:
|
||||
var course_location_analytics = "${locator}";
|
||||
var course_location_analytics = "${locator | escapejs}";
|
||||
%endif
|
||||
|
||||
var analytics=analytics||[];analytics.load=function(e){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"===document.location.protocol?"https://":"http://")+"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"+e+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);var r=function(e){return function(){analytics.push([e].concat(Array.prototype.slice.call(arguments,0)))}},i=["identify","track","trackLink","trackForm","trackClick","trackSubmit","pageview","ab","alias","ready"];for(var s=0;s<i.length;s++)analytics[i[s]]=r(i[s])};
|
||||
@@ -28,7 +30,7 @@
|
||||
<!-- dummy segment.io -->
|
||||
<script type="text/javascript">
|
||||
%if context_course:
|
||||
var course_location_analytics = "${locator}";
|
||||
var course_location_analytics = "${locator | escapejs}";
|
||||
%endif
|
||||
var analytics = {
|
||||
"track": function() {}
|
||||
|
||||
Reference in New Issue
Block a user