提交 e05d4cea 编写于 作者: V Vijay Dev

revert the changes from c60995f3 - related to marking sub,gsub as unavailable...

revert the changes from c60995f3 - related to marking sub,gsub as unavailable to use with safe strings
上级 9987f1e3
......@@ -76,7 +76,6 @@ def html_safe?
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 @@ def #{unsafe_method}!(*args) # def capitalize!(*args)
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册