Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize isn't doing anything? #16

Open
flound1129 opened this issue Aug 18, 2015 · 4 comments
Open

Sanitize isn't doing anything? #16

flound1129 opened this issue Aug 18, 2015 · 4 comments

Comments

@flound1129
Copy link

What am I doing wrong here?

http://jsfiddle.net/fe9pd8uy/

@johnsonjo4531
Copy link

It does work it just returns a document fragment instead of 'foo' like as expected in the docs. Perhaps you want to replace the element with the filtered element like this. http://jsfiddle.net/fe9pd8uy/3/

@flound1129
Copy link
Author

Shouldn't the default code strip all tags and just leave 'foo'? Why is the img tag still there?

@johnsonjo4531
Copy link

What it does when you call sanitize is return a sanitized node. It does not modify the node directly that you select. You need to replace the un-sanitized node with the sanitized one. I tried to explain it a little more in this fiddle what I did in my last fiddle. http://jsfiddle.net/fe9pd8uy/5/

I get the feeling that if you're trying to prevent XSS you probably should never have unsafe dom elements on your page so you would do it more like this. This might be a general use case if that's your case. http://jsfiddle.net/fe9pd8uy/6/.

Sorry for the late reply.

@flound1129
Copy link
Author

OK thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants