From e05d4cea69919ed0a2e5832bde120b5d0f12c0ec Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 9 Sep 2011 01:05:07 +0530 Subject: revert the changes from c60995f3 - related to marking sub,gsub as unavailable to use with safe strings --- .../active_support/core_ext/string/output_safety.rb | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 4c9609c27a..05b39b89bf 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -76,7 +76,6 @@ end module ActiveSupport #:nodoc: class SafeBuffer < String UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase"].freeze - UNAVAILABLE_STRING_METHODS = [] alias_method :original_concat, :concat private :original_concat @@ -155,24 +154,6 @@ module ActiveSupport #:nodoc: EOT end - UNAVAILABLE_STRING_METHODS.each do |unavailable_method| - class_eval <<-EOT, __FILE__, __LINE__ - # def gsub(*args) - # raise NoMethodError, "gsub cannot be used with a safe string. You should use object.to_str.gsub" - # end - def #{unavailable_method}(*args) - raise NoMethodError, "#{unavailable_method} cannot be used with a safe string. You should use object.to_str.#{unavailable_method}" - end - - # def gsub!(*args) - # raise NoMethodError, "gsub! cannot be used with a safe string. You should use object.to_str.gsub!" - # end - def #{unavailable_method}!(*args) - raise NoMethodError, "#{unavailable_method}! cannot be used with a safe string. You should use object.to_str.#{unavailable_method}!" - end - EOT - end - protected def dirty? @@ -185,4 +166,4 @@ class String def html_safe ActiveSupport::SafeBuffer.new(self) end -end \ No newline at end of file +end -- cgit v1.2.3