Land #9912, Fix type validation in the notes add operation

GSoC/Meterpreter_Web_Console
Aaron Soto 2018-04-23 16:58:13 -05:00
commit a1027d56c9
No known key found for this signature in database
GPG Key ID: A974121808B92094
1 changed files with 5 additions and 5 deletions

View File

@ -1056,7 +1056,7 @@ class Db
return return
end end
if types && types.size != 1 if types.nil? || types.size != 1
print_error("Exactly one type is required") print_error("Exactly one type is required")
return return
end end
@ -1078,12 +1078,12 @@ class Db
end end
if mode == :update if mode == :update
if types && types.size != 1 if !types.nil? && types.size != 1
print_error("Exactly one type is required") print_error("Exactly one type is required")
return return
end end
if !types && !data if types.nil? && data.nil?
print_error("Update requires data or type") print_error("Update requires data or type")
return return
end end
@ -1119,12 +1119,12 @@ class Db
if mode == :update if mode == :update
begin begin
update_opts = {id: note.id} update_opts = {id: note.id}
if types unless types.nil?
note.ntype = types.first note.ntype = types.first
update_opts[:ntype] = types.first update_opts[:ntype] = types.first
end end
if data unless data.nil?
note.data = data note.data = data
update_opts[:data] = data update_opts[:data] = data
end end