Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forms: FeedbackLabel: display unescaped description (sanitized HTML) #281

Merged
merged 1 commit into from
Mar 26, 2025
Merged
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
8 changes: 7 additions & 1 deletion src/lib/forms/FeedbackLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ export class FeedbackLabel extends Component {
{hasSeverity && (
<InvenioPopup
trigger={<Icon name="info circle" />}
content={severityInfo.severityDescription}
// Rule descriptions can contain HTML to link to a page with more details about the rule.
// This field is sanitized in the backend with SanitizedHTML.
content={
<span
dangerouslySetInnerHTML={{ __html: severityInfo.severityDescription }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general we try to avoid to use dangerouslySetInnerHTML, I guess we are sure there is no securiy issue

Copy link
Member

@slint slint Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are backend-generated errors that for now don't come from user input, and if/when they do (e.g. for users defining their own checks rules) we'll be sanitizing input.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitization is done in Marshmallow in the other pull request inveniosoftware/invenio-checks#30 (field CheckConfigSchema.description).
Since FeedbackLabel expects either a plain text error, or the new error format from the checks, the risk of this widget being misused should be low.

/>
}
position="top center"
hoverable
/>
Expand Down
Loading