I'm creating a MERN application and normally I would think about SQL injection but I was wondering what should be done for node/mongoDB and if there is something React has that could help with anything that needs to be done to protect inputs.
The application has registration and a user profile, social media structure.
I am also using CKEditor to allow people to save the text formatting for their posts.
But when I display this I am currently using dangerouslySetInnerHTML={{ __html: viewPost.entry }} in the React frontend.
Is there a way to sanitize this going in with CKEditor or a different way to display it without using dangerouslySetInnerHTML?
<CKEditor
editor={ClassicEditor}
data=''
value={entry}
onInit={(editor) => {
// You can store the "editor" and use when it is needed.
// console.log("Editor is ready to use!", editor);
editor.editing.view.change((writer) => {
writer.setStyle(
'height',
'500px',
editor.editing.view.document.getRoot()
);
});
}}
onReady={(editor) => {
// You can store the "editor" and use when it is needed.
console.log('Editor is ready to use!', editor);
}}
onChange={(event, editor) => onChangeInEditor(event, editor)}
onBlur={(event, editor) => {
console.log('Blur.', editor);
}}
onFocus={(event, editor) => {
console.log('Focus.', editor);
}}
/>