Merge pull request #807 from mojombo/safeyaml-warnings
Fix SafeYAML Warnings
This commit is contained in:
commit
d361a70391
|
@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_runtime_dependency('kramdown', "~> 0.14")
|
s.add_runtime_dependency('kramdown', "~> 0.14")
|
||||||
s.add_runtime_dependency('pygments.rb', "~> 0.3.2")
|
s.add_runtime_dependency('pygments.rb', "~> 0.3.2")
|
||||||
s.add_runtime_dependency('commander', "~> 4.1.3")
|
s.add_runtime_dependency('commander', "~> 4.1.3")
|
||||||
s.add_runtime_dependency('safe_yaml', "~> 0.4")
|
s.add_runtime_dependency('safe_yaml', "~> 0.7")
|
||||||
|
|
||||||
s.add_development_dependency('rake', "~> 10.0.3")
|
s.add_development_dependency('rake', "~> 10.0.3")
|
||||||
s.add_development_dependency('rdoc', "~> 3.11")
|
s.add_development_dependency('rdoc', "~> 3.11")
|
||||||
|
|
|
@ -48,6 +48,8 @@ require_all 'jekyll/converters'
|
||||||
require_all 'jekyll/generators'
|
require_all 'jekyll/generators'
|
||||||
require_all 'jekyll/tags'
|
require_all 'jekyll/tags'
|
||||||
|
|
||||||
|
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
VERSION = '0.12.0'
|
VERSION = '0.12.0'
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ module Jekyll
|
||||||
# Get configuration from <source>/_config.yml
|
# Get configuration from <source>/_config.yml
|
||||||
config_file = File.join(source, '_config.yml')
|
config_file = File.join(source, '_config.yml')
|
||||||
begin
|
begin
|
||||||
config = YAML.load_file(config_file)
|
config = YAML.safe_load_file(config_file)
|
||||||
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
||||||
$stdout.puts "Configuration from #{config_file}"
|
$stdout.puts "Configuration from #{config_file}"
|
||||||
rescue => err
|
rescue => err
|
||||||
|
|
|
@ -30,7 +30,7 @@ module Jekyll
|
||||||
|
|
||||||
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
||||||
self.content = $POSTMATCH
|
self.content = $POSTMATCH
|
||||||
self.data = YAML.load($1)
|
self.data = YAML.safe_load($1)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Error reading file #{File.join(base, name)}: #{e.message}"
|
puts "Error reading file #{File.join(base, name)}: #{e.message}"
|
||||||
|
|
|
@ -7,20 +7,20 @@ class TestConfiguration < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "fire warning with no _config.yml" do
|
should "fire warning with no _config.yml" do
|
||||||
mock(YAML).load_file(@path) { raise "No such file or directory - #{@path}" }
|
mock(YAML).safe_load_file(@path) { raise "No such file or directory - #{@path}" }
|
||||||
mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).")
|
mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).")
|
||||||
mock($stderr).puts("\tNo such file or directory - #{@path}")
|
mock($stderr).puts("\tNo such file or directory - #{@path}")
|
||||||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
||||||
end
|
end
|
||||||
|
|
||||||
should "load configuration as hash" do
|
should "load configuration as hash" do
|
||||||
mock(YAML).load_file(@path) { Hash.new }
|
mock(YAML).safe_load_file(@path) { Hash.new }
|
||||||
mock($stdout).puts("Configuration from #{@path}")
|
mock($stdout).puts("Configuration from #{@path}")
|
||||||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
||||||
end
|
end
|
||||||
|
|
||||||
should "fire warning with bad config" do
|
should "fire warning with bad config" do
|
||||||
mock(YAML).load_file(@path) { Array.new }
|
mock(YAML).safe_load_file(@path) { Array.new }
|
||||||
mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).")
|
mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).")
|
||||||
mock($stderr).puts("\tInvalid configuration - #{@path}")
|
mock($stderr).puts("\tInvalid configuration - #{@path}")
|
||||||
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
|
||||||
|
|
Loading…
Reference in New Issue