i have my react quill component, which returns something like this
EXAMPLE:
<p><br></p><p>fsdafsd</p><p>fsdfsda</p><p>fsdafsad</p
and that is content, and i wanna save it into database, but i'm not sure, i don't think that i have to save it as string because someone can imbed script into itt and it's not safe, can you help me how can i do this,
also when i'm saving it into dataabse i wanna somehow get same html string from database, to display it into website
i just tried to use library, to remove this html characters, but it saves only plane text, and i wanna retreat it from database as it was saved like html
You should save HTML content in database by encoding it to prevent security vulnerabilities or data corruption. If HTML saved as row it will make your application vulnerable to XSS attack.
In plain javascript you can use inbuilt
escapefunction to encode andunescapeto decodeyou can also create own encode / decode logic and use based on your requirement.