Last active
December 14, 2015 00:48
-
-
Save presidentbeef/5001099 to your computer and use it in GitHub Desktop.
String#html_safe does not make a string HTML safe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading development environment (Rails 3.2.11) | |
1.9.3p374 :001 > s = "<script>alert('hello')</script>" | |
=> "<script>alert('hello')</script>" | |
1.9.3p374 :002 > ERB::Util.html_escape s | |
=> "<script>alert('hello')</script>" | |
1.9.3p374 :003 > safe = s.html_safe | |
=> "<script>alert('hello')</script>" | |
1.9.3p374 :004 > ERB::Util.html_escape safe | |
=> "<script>alert('hello')</script>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment