apache / couchdb-fauxton

Fauxton is the new Web UI for CouchDB
https://github.com/apache/couchdb-fauxton
Apache License 2.0
373 stars 225 forks source link

Remove some uses of "dangerouslySetInnerHTML" #1407

Closed Antonio-Maranhao closed 11 months ago

Antonio-Maranhao commented 11 months ago

Overview

The dangerouslySetInnerHTML React property was being used by Notification components to allow formatting of the message by embedding HTML elements directly in the message. This flexibility can become a security issue because messages might include data provided by users (e.g. document IDs), in which case it can be used for HTML injection.

This PR removes uses of dangerouslySetInnerHTML in the Notification components in favor of embedding the input msg as a normal React node, which then is properly sanitized by React.

Testing recommendations

Test notifications: e.g. create or delete a document and validate the notification is still displayed.

GitHub issue number

n/a

Related Pull Requests

n/a

Checklist

pgj commented 11 months ago

Nitpick: the name of the React property misses an 's' in the PR description and title sometimes, i.e. written as dangeroulySetInnerHTML.

Antonio-Maranhao commented 11 months ago

Fixed. Thanks @pgj