aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support.rb53
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb29
-rw-r--r--activesupport/lib/active_support/dependencies/autoload.rb10
-rw-r--r--activesupport/lib/active_support/json/encoding.rb13
-rw-r--r--activesupport/lib/active_support/whiny_nil.rb5
-rw-r--r--activesupport/test/json/encoding_test.rb4
6 files changed, 55 insertions, 59 deletions
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index 9e21b3faf3..f2baa5a56a 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -39,31 +39,34 @@ require "active_support/dependencies/autoload"
module ActiveSupport
extend ActiveSupport::Autoload
- autoload :BacktraceCleaner
- autoload :Base64
- autoload :BasicObject
- autoload :Benchmarkable
- autoload :BufferedLogger
- autoload :Cache
- autoload :Callbacks
- autoload :Concern
- autoload :Configurable
- autoload :DeprecatedCallbacks
- autoload :Deprecation
- autoload :Gzip
- autoload :Inflector
- autoload :Memoizable
- autoload :MessageEncryptor
- autoload :MessageVerifier
- autoload :Multibyte
- autoload :OptionMerger
- autoload :OrderedHash
- autoload :OrderedOptions
- autoload :Notifications
- autoload :Rescuable
- autoload :SecureRandom
- autoload :StringInquirer
- autoload :XmlMini
+ # TODO: Narrow this list down
+ eager_autoload do
+ autoload :BacktraceCleaner
+ autoload :Base64
+ autoload :BasicObject
+ autoload :Benchmarkable
+ autoload :BufferedLogger
+ autoload :Cache
+ autoload :Callbacks
+ autoload :Concern
+ autoload :Configurable
+ autoload :DeprecatedCallbacks
+ autoload :Deprecation
+ autoload :Gzip
+ autoload :Inflector
+ autoload :Memoizable
+ autoload :MessageEncryptor
+ autoload :MessageVerifier
+ autoload :Multibyte
+ autoload :OptionMerger
+ autoload :OrderedHash
+ autoload :OrderedOptions
+ autoload :Notifications
+ autoload :Rescuable
+ autoload :SecureRandom
+ autoload :StringInquirer
+ autoload :XmlMini
+ end
end
require 'active_support/vendor'
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 a2a88eb7df..3e6ab0ebd2 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -1,7 +1,6 @@
class String
- def html_safe?
- defined?(@_rails_html_safe) && @_rails_html_safe
- end
+ attr_accessor :_rails_html_safe
+ alias html_safe? _rails_html_safe
def html_safe!
@_rails_html_safe = true
@@ -15,30 +14,16 @@ class String
alias original_plus +
def +(other)
result = original_plus(other)
- if html_safe? && also_html_safe?(other)
- result.html_safe!
- else
- result
- end
+ result._rails_html_safe = html_safe? && other.html_safe?
+ result
end
alias original_concat <<
+ alias safe_concat <<
def <<(other)
+ @_rails_html_safe = false unless other.html_safe?
result = original_concat(other)
- unless html_safe? && also_html_safe?(other)
- @_rails_html_safe = false
- end
- result
end
- remove_method :concat
- def concat(other)
- self << other
- end
-
- private
- def also_html_safe?(other)
- other.respond_to?(:html_safe?) && other.html_safe?
- end
-
+ alias concat <<
end \ No newline at end of file
diff --git a/activesupport/lib/active_support/dependencies/autoload.rb b/activesupport/lib/active_support/dependencies/autoload.rb
index 96ab04c61a..44edb89ad5 100644
--- a/activesupport/lib/active_support/dependencies/autoload.rb
+++ b/activesupport/lib/active_support/dependencies/autoload.rb
@@ -5,13 +5,13 @@ module ActiveSupport
@@autoloads = {}
@@under_path = nil
@@at_path = nil
- @@autoload_defer = false
+ @@eager_autoload = false
def autoload(const_name, path = @@at_path)
full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
location = path || Inflector.underscore(full)
- unless @@autoload_defer
+ if @@eager_autoload
@@autoloads[const_name] = location
end
super const_name, location
@@ -31,11 +31,11 @@ module ActiveSupport
@@at_path = old_path
end
- def deferrable
- old_defer, @@autoload_defer = @@autoload_defer, true
+ def eager_autoload
+ old_eager, @@eager_autoload = @@eager_autoload, true
yield
ensure
- @@autoload_defer = old_defer
+ @@eager_autoload = old_eager
end
def self.eager_autoload!
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index 3c15056c41..c8415d5449 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -65,6 +65,15 @@ module ActiveSupport
ESCAPED_CHARS = {
+ "\x00" => '\u0000', "\x01" => '\u0001', "\x02" => '\u0002',
+ "\x03" => '\u0003', "\x04" => '\u0004', "\x05" => '\u0005',
+ "\x06" => '\u0006', "\x07" => '\u0007', "\x0B" => '\u000B',
+ "\x0E" => '\u000E', "\x0F" => '\u000F', "\x10" => '\u0010',
+ "\x11" => '\u0011', "\x12" => '\u0012', "\x13" => '\u0013',
+ "\x14" => '\u0014', "\x15" => '\u0015', "\x16" => '\u0016',
+ "\x17" => '\u0017', "\x18" => '\u0018', "\x19" => '\u0019',
+ "\x1A" => '\u001A', "\x1B" => '\u001B', "\x1C" => '\u001C',
+ "\x1D" => '\u001D', "\x1E" => '\u001E', "\x1F" => '\u001F',
"\010" => '\b',
"\f" => '\f',
"\n" => '\n',
@@ -86,9 +95,9 @@ module ActiveSupport
def escape_html_entities_in_json=(value)
self.escape_regex = \
if @escape_html_entities_in_json = value
- /[\010\f\n\r\t"\\><&]/
+ /[\x00-\x1F"\\><&]/
else
- /[\010\f\n\r\t"\\]/
+ /[\x00-\x1F"\\]/
end
end
diff --git a/activesupport/lib/active_support/whiny_nil.rb b/activesupport/lib/active_support/whiny_nil.rb
index c3ed659d6b..4f6ff7d3b5 100644
--- a/activesupport/lib/active_support/whiny_nil.rb
+++ b/activesupport/lib/active_support/whiny_nil.rb
@@ -43,10 +43,7 @@ class NilClass
private
def method_missing(method, *args, &block)
- # Ruby 1.9.2: disallow explicit coercion via method_missing.
- if method == :to_ary || method == :to_str
- raise NoMethodError, "undefined method `#{method}' for nil:NilClass"
- elsif klass = METHOD_CLASS_MAP[method]
+ if klass = METHOD_CLASS_MAP[method]
raise_nil_warning_for klass, method, caller
else
super
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index 5d81d09f03..cf9a635b5f 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -23,7 +23,9 @@ class TestJSONEncoding < Test::Unit::TestCase
StringTests = [[ 'this is the <string>', %("this is the \\u003Cstring\\u003E")],
[ 'a "string" with quotes & an ampersand', %("a \\"string\\" with quotes \\u0026 an ampersand") ],
- [ 'http://test.host/posts/1', %("http://test.host/posts/1")]]
+ [ 'http://test.host/posts/1', %("http://test.host/posts/1")],
+ [ "Control characters: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+ %("Control characters: \\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000B\\f\\r\\u000E\\u000F\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F") ]]
ArrayTests = [[ ['a', 'b', 'c'], %([\"a\",\"b\",\"c\"]) ],
[ [1, 'a', :b, nil, false], %([1,\"a\",\"b\",null,false]) ]]