diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 5c23196e71..0c8b4b6337 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -36,7 +36,8 @@ from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.inheritance import own_metadata from opaque_keys.edx.keys import UsageKey, CourseKey from opaque_keys.edx.locations import AssetLocation, CourseLocator -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory, check_mongo_calls +from xmodule.modulestore.tests.utils import XssTestMixin from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_importer import import_course_from_xml, perform_xlint @@ -1115,7 +1116,7 @@ class MiscCourseTests(ContentStoreTestCase): @ddt.ddt -class ContentStoreTest(ContentStoreTestCase): +class ContentStoreTest(ContentStoreTestCase, XssTestMixin): """ Tests for the CMS ContentStore application. """ @@ -1405,6 +1406,22 @@ class ContentStoreTest(ContentStoreTestCase): html=True ) + def test_course_index_view_xss(self): + """Test that the index page correctly escapes course names with script + tags.""" + CourseFactory.create( + display_name='' + ) + + LibraryFactory.create(display_name='') + + resp = self.client.get_html('/home/') + for xss in ('course', 'library'): + html = ''.format( + name=xss + ) + self.assert_xss(resp, html) + def test_course_overview_view_with_course(self): """Test viewing the course overview page with an existing course""" course = CourseFactory.create() diff --git a/cms/templates/course-create-rerun.html b/cms/templates/course-create-rerun.html index 44f828192f..6affe2129f 100644 --- a/cms/templates/course-create-rerun.html +++ b/cms/templates/course-create-rerun.html @@ -40,7 +40,7 @@ from django.template.defaultfilters import escapejs