diff options
Diffstat (limited to 'actionpack/lib/action_view/safe_buffer.rb')
-rw-r--r-- | actionpack/lib/action_view/safe_buffer.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/safe_buffer.rb b/actionpack/lib/action_view/safe_buffer.rb new file mode 100644 index 0000000000..8ba9cd80d6 --- /dev/null +++ b/actionpack/lib/action_view/safe_buffer.rb @@ -0,0 +1,28 @@ + +module ActionView #:nodoc: + class SafeBuffer < String + def <<(value) + if value.html_safe? + super(value) + else + super(CGI.escapeHTML(value)) + end + end + + def concat(value) + self << value + end + + def html_safe? + true + end + + def html_safe! + self + end + + def to_s + self + end + end +end
\ No newline at end of file |