New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Help
I an error occurring here https://code.sololearn.com/Wm2GvuhgKY0L/?ref=app
5 Answers
+ 2
Where? Describe the error precisely.
+ 2
👉 Describe the error.
What happened?
Where did you run the code?
What does the error message say?
0
In the code
0
Code seems working fine... Where is error?
0
Your code is vulnerable to HTML injection and rendering issues. For example if you type in the input `<p> Hello World </p>` In the page it will show Hello world. Here is a better example: typing <button> </button> to the code will make a button. By directly inserting user input as HTML content, HTML injections are possible since the input is HTML content. The updated code addresses these weak points by using `textContent` to safely render user input as plain text, preventing HTML injection and XSS attacks. While this isn't necessary in a small project just for fun, if your creating huge projects you should make sure there isn't vulnerabilities like the one I stated.
Here is my version of your code: https://www.sololearn.com/compiler-playground/Wzn6lKbNKHdI
I only changed the content inside the Script tag