Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openedx/core/lib/tests/test_xblock_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def test_wrap_xblock(self):

def test_sanitize_html_id(self):
"""
Verify that colons and dashes are replaced.
Verify that colons, dashes, and periods are replaced.
"""
dirty_string = 'I:have-un:allowed_characters'
dirty_string = 'I:have-un:allowed.characters'
clean_string = sanitize_html_id(dirty_string)

assert clean_string == 'I_have_un_allowed_characters'
Expand Down
6 changes: 4 additions & 2 deletions openedx/core/lib/xblock_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ def grade_histogram(block_id):

def sanitize_html_id(html_id):
"""
Template uses element_id in js function names, so can't allow dashes and colons.
Template uses element_id in js function names, and as a raw (unescaped) jQuery/CSS
ID selector (e.g. leanModal's `$(anchor.attr('href'))`), so it can't contain
dashes, colons, or periods.
"""
sanitized_html_id = re.sub(r'[:-]', '_', html_id)
sanitized_html_id = re.sub(r'[:\-.]', '_', html_id)
return sanitized_html_id


Expand Down
Loading