Workaround for Ruby 1.8's fragile Marshal code

git-svn-id: file:///home/svn/framework3/trunk@9689 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2010-07-06 18:35:49 +00:00
parent 7384dec65e
commit ef3dbf3841
1 changed files with 6 additions and 1 deletions

View File

@ -2594,7 +2594,12 @@ class DBManager
return nil if not string
return nil if string.empty?
begin
Marshal.load(string.unpack("m")[0])
# Validate that it is properly formed base64 first
if string.gsub(/\s+/, '') =~ /^([a-z0-9A-Z\+\/=]+)$/
Marshal.load($1.unpack("m")[0])
else
string
end
rescue ::Exception => e
if allow_yaml
YAML.load(string) rescue string