diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-04 16:52:47 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-04 16:52:47 -0800 |
commit | 7bd32e4d1d7b5ffe300ce667dd8daa17a2a9ad26 (patch) | |
tree | 61ef6aa95633fa4a97ec8dfe76d2e2912c1bdabd /activesupport/lib | |
parent | 3f4143eedb3ec1c8e55bfc1ea0083fbb35749659 (diff) | |
download | rails-7bd32e4d1d7b5ffe300ce667dd8daa17a2a9ad26.tar.gz rails-7bd32e4d1d7b5ffe300ce667dd8daa17a2a9ad26.tar.bz2 rails-7bd32e4d1d7b5ffe300ce667dd8daa17a2a9ad26.zip |
add Psych::SyntaxError to the list of rescued YAML exceptions
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/json/backends/yaml.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/backends/yaml.rb b/activesupport/lib/active_support/json/backends/yaml.rb index 4cb9d01077..2e389b5c12 100644 --- a/activesupport/lib/active_support/json/backends/yaml.rb +++ b/activesupport/lib/active_support/json/backends/yaml.rb @@ -7,13 +7,20 @@ module ActiveSupport ParseError = ::StandardError extend self + EXCEPTIONS = [::ArgumentError] # :nodoc: + begin + require 'psych' + EXCEPTIONS << Psych::SyntaxError + rescue LoadError + end + # Parses a JSON string or IO and converts it into an object def decode(json) if json.respond_to?(:read) json = json.read end YAML.load(convert_json_to_yaml(json)) - rescue ArgumentError + rescue *EXCEPTIONS raise ParseError, "Invalid JSON string" end |