mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
revert the changes from c60995f3
- related to marking sub,gsub as unavailable to use with safe strings
This commit is contained in:
parent
9987f1e34d
commit
e05d4cea69
1 changed files with 1 additions and 20 deletions
|
@ -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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue