-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
HTML escape #51
HTML escape #51
Conversation
Changes Unknown when pulling 84e3bae on html-escape into * on master*. |
Changes Unknown when pulling cace05a on html-escape into * on master*. |
Looks great, and easy enough to follow... |
# @since x.x.x | ||
# @api private | ||
# | ||
# @see http://www.ruby-doc.org/Fixnum.html#method-i-to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page not found, the message in the web:
We're sorry, but that page cannot be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlfonsoUceda Fixed, thanks 👍
👍 @jodosha I learn a lot reading your code ;) and tomorrow I'll see the references posted above. |
Changes Unknown when pulling f5fc4cc on html-escape into * on master*. |
Changes Unknown when pulling bc940ba on html-escape into * on master*. |
Changes Unknown when pulling d9225cb on html-escape into * on master*. |
…et devs to mark a string as safe
Feature
Escape utilities for HTML contents and attributes
HTML escape utilities
Based on OWASP research and OWASP ESAPI code
See:
https://www.owasp.org
https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
https://www.owasp.org/index.php/ESAPI
https://github.com/ESAPI/esapi-java-legacy
Ref: hanami/helpers#7
Technical notes
Lookup chars
It internally uses Hash instances to lookup chars.
They are implemented with this syntax
{ 0x9f => true }
, which makes them equivalent toSet.new([0x9f])
, but the lookup is faster: https://gist.github.com/jodosha/ac5dd54416de744b9600Output class
The output is a
Lotus::Utils::Escape::SafeString
instance. This is a private class that is required for two reasons:Lotus::Helpers
compatibility)#raw
inLotus::View
orLotus::Helpers
)