-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5121 from open-formulieren/issue/html-in-componen…
…t-tooltip Sanitizing HTML from component label, tooltip and description
- Loading branch information
Showing
10 changed files
with
467 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from openforms.formio.typing import Component | ||
from openforms.utils.sanitizer import sanitize_html_content | ||
|
||
|
||
def sanitize_component(component: Component): | ||
""" | ||
Sanitize content of any form component. | ||
The tooltip, description and label content will be replaced with a sanitized version. | ||
All tags and attributes that aren't explicitly allowed, are removed from the | ||
component content. | ||
:arg component: the component data. | ||
""" | ||
if "tooltip" in component: | ||
component["tooltip"] = sanitize_html_content(component["tooltip"]) | ||
if "description" in component: | ||
component["description"] = sanitize_html_content(component["description"]) | ||
if "label" in component: | ||
component["label"] = sanitize_html_content(component["label"]) |
Oops, something went wrong.