Safe loading of files and YAML.
This commit is contained in:
parent
0c6d56365a
commit
11eb1ecae1
|
@ -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}"
|
||||||
|
|
Loading…
Reference in New Issue