Don't crash when reading/writing Marshal
This commit is contained in:
parent
73db98c244
commit
376c87b62e
|
@ -130,7 +130,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def write_metadata
|
def write_metadata
|
||||||
File.open(metadata_file, 'w') do |f|
|
File.open(metadata_file, 'wb') do |f|
|
||||||
f.write(Marshal.dump(metadata))
|
f.write(Marshal.dump(metadata))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -164,6 +164,9 @@ module Jekyll
|
||||||
Marshal.load(content)
|
Marshal.load(content)
|
||||||
rescue TypeError
|
rescue TypeError
|
||||||
SafeYAML.load(content)
|
SafeYAML.load(content)
|
||||||
|
rescue ArgumentError => e
|
||||||
|
Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
|
||||||
|
{}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
|
Loading…
Reference in New Issue