[why] When parsing user_info from the mail content, user_info may be nil if it's empty or a empty line. It may throw 'has no include? method for nil' error when use user_info.include?
Signed-off-by: Luan Shengde shdluan@163.com --- container/mail-robot/lib/parse-apply-account-email.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/container/mail-robot/lib/parse-apply-account-email.rb b/container/mail-robot/lib/parse-apply-account-email.rb index 272f1a1..e6c35f7 100755 --- a/container/mail-robot/lib/parse-apply-account-email.rb +++ b/container/mail-robot/lib/parse-apply-account-email.rb @@ -63,8 +63,10 @@ class ParseApplyAccountEmail users.delete('') users.each do |user| user_info = YAML.safe_load(user) + next if user_info.nil? + next unless user_info.include?('my_email')
- users_info << user_info if user_info.include?('my_email') + users_info << user_info end
return users_info