aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-01 09:51:51 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-03-01 09:51:51 -0800
commitc2897901de4266e5c02da6cc5a9348bfde13552e (patch)
tree6efe811c1c6e074fcac0daae63b9d9bf7634e995 /activesupport/lib
parent5bb5780f7b2015f3f948f39e0151198591757056 (diff)
parent01b470f526922ad3fc5562a237d11d45347befa9 (diff)
downloadrails-c2897901de4266e5c02da6cc5a9348bfde13552e.tar.gz
rails-c2897901de4266e5c02da6cc5a9348bfde13552e.tar.bz2
rails-c2897901de4266e5c02da6cc5a9348bfde13552e.zip
Merge branch '3-2-2' into 3-2-stable
* 3-2-2: bumping to 3.2.2 Ensure [] respects the status of the buffer. Merge pull request #4834 from sskirby/fix_usage_of_psql_in_db_test_prepare Merge pull request #5084 from johndouthat/patch-1 updating RAILS_VERSION delete vulnerable AS::SafeBuffer#[] use AS::SafeBuffer#clone_empty for flushing the output_buffer add AS::SafeBuffer#clone_empty fix output safety issue with select options
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb38
-rw-r--r--activesupport/lib/active_support/version.rb2
2 files changed, 23 insertions, 17 deletions
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 c6d861d124..4089b02d45 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -98,29 +98,41 @@ module ActiveSupport #:nodoc:
end
end
- def[](*args)
- new_safe_buffer = super
- new_safe_buffer.instance_eval { @dirty = false }
- new_safe_buffer
+ def [](*args)
+ return super if args.size < 2
+
+ if html_safe?
+ new_safe_buffer = super
+ new_safe_buffer.instance_eval { @html_safe = true }
+ new_safe_buffer
+ else
+ to_str[*args]
+ end
end
def safe_concat(value)
- raise SafeConcatError if dirty?
+ raise SafeConcatError unless html_safe?
original_concat(value)
end
def initialize(*)
- @dirty = false
+ @html_safe = true
super
end
def initialize_copy(other)
super
- @dirty = other.dirty?
+ @html_safe = other.html_safe?
+ end
+
+ def clone_empty
+ new_safe_buffer = self[0, 0]
+ new_safe_buffer.instance_variable_set(:@dirty, @dirty)
+ new_safe_buffer
end
def concat(value)
- if dirty? || value.html_safe?
+ if !html_safe? || value.html_safe?
super(value)
else
super(ERB::Util.h(value))
@@ -133,7 +145,7 @@ module ActiveSupport #:nodoc:
end
def html_safe?
- !dirty?
+ defined?(@html_safe) && @html_safe
end
def to_s
@@ -161,18 +173,12 @@ module ActiveSupport #:nodoc:
end # end
def #{unsafe_method}!(*args) # def capitalize!(*args)
- @dirty = true # @dirty = true
+ @html_safe = false # @html_safe = false
super # super
end # end
EOT
end
end
-
- protected
-
- def dirty?
- @dirty
- end
end
end
diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb
index ef2c69e695..597099eef3 100644
--- a/activesupport/lib/active_support/version.rb
+++ b/activesupport/lib/active_support/version.rb
@@ -2,7 +2,7 @@ module ActiveSupport
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 1
+ TINY = 2
PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')