From the course: JavaScript: Security Essentials

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Final syntax applied XSS

Final syntax applied XSS - JavaScript Tutorial

From the course: JavaScript: Security Essentials

Start my 1-month free trial

Final syntax applied XSS

- [Instructor] So let's take a look at how you do it in this particular example, or how you would resolve any securities issue. So the first thing you'd need to do in a React application is to change the innerHTML to what's called dangerouslySetInnerHTML. So by doing this, you're telling React that this is safe, although you can go back to this and read dangerouslySetInnerHTML, that means that this is dangerous. So if we go back to the application here and scroll down, now, I am so dangerous you can feel it, is actually showing. But this is not ideal. So in a React application, you can use a state for that. So if we go back to our code here, you could use the state to kind of put that particular text here inside of the state and then leverage the syntax to actually name it here. So in a perfect world, this is what you would do in a React application, but we're talking about JavaScript, in general. There are some rules that you want to follow when you want to make sure that you're not…

Contents