fix: update sanitize_html_id to replace periods along with dashes and…#38871
Open
alenkadev wants to merge 2 commits into
Open
fix: update sanitize_html_id to replace periods along with dashes and…#38871alenkadev wants to merge 2 commits into
alenkadev wants to merge 2 commits into
Conversation
Alam-2U
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Staff debug info button does not work on EPFLx+drug-discovery (Introduction to Drug Discovery)
Root cause
Some older/imported XBlocks can have block IDs containing periods (.), for example question_1.4.100. These IDs are used to generate the HTML IDs for the staff tooling modals (Staff Debug Info, Submission History, and QA).
The staff tooling uses the generated IDs directly as jQuery/CSS selectors through LeanModal. Since periods are interpreted as CSS selector syntax rather than literal characters, the selector fails to locate the modal element. As a result, clicking Staff Debug Info dims the page but the modal never appears.
Newly created or duplicated XBlocks are not affected because they receive auto-generated alphanumeric IDs (UUIDs), which do not contain periods.
Solution
Extend sanitize_html_id() to replace periods (.) with underscores (_) in addition to the characters it already sanitizes (: and -).
This ensures that all HTML IDs generated for staff tooling are safe to use as unescaped jQuery/CSS selectors, allowing the Staff Debug Info, Submission History, and QA modals to open correctly for XBlocks regardless of how their block IDs were originally created.
before fix:
after fix:
jira_link: https://2u-internal.atlassian.net/browse/LP-849