Don't crash when reading/writing Marshal

This commit is contained in:
Florian Weingarten 2015-05-19 15:51:55 +00:00
parent 73db98c244
commit 376c87b62e
1 changed files with 4 additions and 1 deletions

View File

@ -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
{} {}