Commit f336d049 by Waheed Ahmed

Html escaped from display name in xblock.

LMS-11194
parent 7225420f
...@@ -25,7 +25,7 @@ Feature: CMS.Course Outline ...@@ -25,7 +25,7 @@ Feature: CMS.Course Outline
Scenario: Collapse link is removed after last section of a course is deleted Scenario: Collapse link is removed after last section of a course is deleted
Given I have a course with 1 section Given I have a course with 1 section
And I navigate to the course outline page And I navigate to the course outline page
And I press the "section" delete icon And I press the section delete icon
When I will confirm all alerts When I will confirm all alerts
Then I do not see the "Collapse All Sections" link Then I do not see the "Collapse All Sections" link
......
...@@ -67,7 +67,7 @@ def i_add_a_section(step): ...@@ -67,7 +67,7 @@ def i_add_a_section(step):
add_section() add_section()
@step(u'I press the "section" delete icon') @step(u'I press the section delete icon')
def i_press_the_section_delete_icon(step): def i_press_the_section_delete_icon(step):
delete_locator = 'section .outline-section > .section-header a.delete-button' delete_locator = 'section .outline-section > .section-header a.delete-button'
world.css_click(delete_locator) world.css_click(delete_locator)
......
...@@ -30,6 +30,12 @@ Feature: CMS.Problem Editor ...@@ -30,6 +30,12 @@ Feature: CMS.Problem Editor
Then I can revert the display name to unset Then I can revert the display name to unset
And my display name is unset on save And my display name is unset on save
Scenario: User can specify html in display name and it will be escaped
Given I have created a Blank Common Problem
When I edit and select Settings
Then I can specify html in the display name and save
And the problem display name is "<script>alert('test')</script>"
# IE will not click the revert button properly # IE will not click the revert button properly
@skip_internetexplorer @skip_internetexplorer
Scenario: User can select values in a Select Scenario: User can select values in a Select
......
...@@ -133,6 +133,18 @@ def i_can_modify_the_display_name_with_special_chars(_step): ...@@ -133,6 +133,18 @@ def i_can_modify_the_display_name_with_special_chars(_step):
verify_modified_display_name_with_special_chars() verify_modified_display_name_with_special_chars()
@step('I can specify html in the display name and save')
def i_can_modify_the_display_name_with_html(_step):
"""
If alert appear on save then UnexpectedAlertPresentException
will occur and test will fail.
"""
index = world.get_setting_entry_index(DISPLAY_NAME)
world.set_field_value(index, "<script>alert('test')</script>")
verify_modified_display_name_with_html()
world.save_component()
@step('my special characters and persisted on save') @step('my special characters and persisted on save')
def special_chars_persisted_on_save(step): def special_chars_persisted_on_save(step):
world.save_component_and_reopen(step) world.save_component_and_reopen(step)
...@@ -350,6 +362,10 @@ def verify_modified_display_name_with_special_chars(): ...@@ -350,6 +362,10 @@ def verify_modified_display_name_with_special_chars():
world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, "updated ' \" &", True) world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, "updated ' \" &", True)
def verify_modified_display_name_with_html():
world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, "<script>alert('test')</script>", True)
def verify_unset_display_name(): def verify_unset_display_name():
world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, 'Blank Advanced Problem', False) world.verify_setting_entry(world.get_setting_entry(DISPLAY_NAME), DISPLAY_NAME, 'Blank Advanced Problem', False)
......
...@@ -231,7 +231,7 @@ class XModuleMixin(XBlockMixin): ...@@ -231,7 +231,7 @@ class XModuleMixin(XBlockMixin):
name = self.display_name name = self.display_name
if name is None: if name is None:
name = self.url_name.replace('_', ' ') name = self.url_name.replace('_', ' ')
return name return name.replace('<', '&lt;').replace('>', '&gt;')
@property @property
def xblock_kvs(self): def xblock_kvs(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment