Created
April 26, 2017 20:57
-
-
Save samandmoore/c06b47e5d338d99625e4ac9c616ffb23 to your computer and use it in GitHub Desktop.
output safety rubocop issues
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
$ rails c | |
Loading development environment (Rails 4.2.7.1) | |
irb(main):001:0> include ActionView::Helpers::OutputSafetyHelper | |
=> Object | |
irb(main):002:0> raw "foo" | |
=> "foo" | |
irb(main):003:0> thing = raw "foo" | |
=> "foo" | |
irb(main):004:0> thing.class | |
=> ActiveSupport::SafeBuffer | |
irb(main):005:0> result = thing + thing | |
=> "foofoo" | |
irb(main):006:0> result.class | |
=> ActiveSupport::SafeBuffer | |
irb(main):007:0> result = thing + "bar" | |
=> "foobar" | |
irb(main):008:0> result.class | |
=> ActiveSupport::SafeBuffer | |
irb(main):009:0> result = thing + "<p>bar</p>" | |
=> "foo<p>bar</p>" | |
irb(main):010:0> result.class | |
=> ActiveSupport::SafeBuffer | |
irb(main):011:0> result | |
=> "foo<p>bar</p>" | |
irb(main):012:0> safe_join([raw("foo"), "<p>bar</p>".html_safe]) | |
=> "foo<p>bar</p>" | |
irb(main):013:0> result = safe_join([raw("foo"), "<p>bar</p>".html_safe]) | |
=> "foo<p>bar</p>" | |
irb(main):014:0> result.class | |
=> ActiveSupport::SafeBuffer | |
irb(main):015:0> result.to_s | |
=> "foo<p>bar</p>" | |
irb(main):016:0> result = safe_join([raw("foo"), "<p>bar</p>".html_safe]) # rubocop:disable OutputSaftey^C | |
irb(main):016:0> result = thing.safe_concat "<p>bar</p>" | |
=> "foo<p>bar</p>" | |
irb(main):017:0> result = thing + "<p>bar</p>" | |
=> "foo<p>bar</p><p>bar</p>" | |
irb(main):018:0> result = thing.safe_concat "<p>bar</p>" | |
=> "foo<p>bar</p><p>bar</p>" | |
irb(main):019:0> safe_join | |
safe_join | |
irb(main):019:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment