-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Regular expressions aren’t the right way #223
Comments
The FYI your example doesn't pass through the filter <a>alert(42);[removed]');document.close();">Hello</a> |
Well, I seem to be using the latest version (1.5.1), and here’s the result:
If you’d like a pull request that uses an HTML parser of some sort, by the way, I would be very happy to do that. Thanks. |
Ah, you're right. I wasn't escaping the backslashes inside the write(). I'd gladly accept a PR. The library is due for a major (api-breaking) update and cleanup soon so maybe it's best to wait for that. |
What about combining with Google's Caja sanitation engine? Here's a quick snippet comparing validator and a node port of Caja called sanitizer.
|
Just tell people to use that instead; separate is better. |
Looks like Caja is written in Java |
The node port comes with the following warning
I'll probably just remove |
Here's an SO post regarding (somewhat) its efficacy. There's a javascript port (Google written by the looks of it) that the post links to. It's apparently white-list based and configurable. I've just been using it out-of-the-box. |
The xss() function was originally a port of the XSS filter from CodeIgniter. I added it to the library because there wasn't an alternative at the time. Unfortunately I don't have the time or expertise to maintain the XSS filter or keep merging upstream changes. If you need one for your app, I suggest looking at Caja sanitisation engine maintained by Google. (https://code.google.com/p/google-caja/ source/browse/trunk/src/com/google/caja/plugin/html-sanitizer.js) Closes #123, #138, #181, #206, #210, #221, #223, #226, #227, #231, #232
A blacklist is also not the right way.
The text was updated successfully, but these errors were encountered: