-
Notifications
You must be signed in to change notification settings - Fork 958
Closed
Labels
Milestone
Description
Since innerHTML assignments can lead to unintended side effects it should be clear to consumers of these APIs when data may lead to an innerHTML assignment.
An example of an assignment which should probably be clearer:
import ipywidgets as widgets
widgets.Checkbox(description="<marquee>this is html</marquee>")Potential ways to address this:
- Switch to textContent assignments. This is the easiest to audit and in many cases may be what users expect.
- Use a sanitizer to sanitize the text before assigning to innerHTML. Good for cases where you want to allow rich content but not arbitrary code execution.
- Require an opt-in to use innerHTML or to disable sanitization.
From a quick glance, a few places that could be worth changing:
this.descriptionSpan.innerHTML = description; this.label.innerHTML = description; button.innerHTML = item_html; this.datalist.innerHTML = optLines.join('\n');