Commit 86e1f41b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Check against "Auto-Submitted: no" instead

This would be much more accurate. We assume this is an
auto-generated email if such header is provided, and
the value is not "no". It could also be: "auto-generated",
"auto-replied", or other values from extension. It seems
that only "no" could mean that this is sent by a human.

See: https://tools.ietf.org/html/rfc3834
parent f097e4db
......@@ -27,8 +27,7 @@ module Gitlab
mail = build_mail
raise AutoGeneratedEmailError if
mail.header.to_s =~ /auto-(generated|replied)/
ignore_auto_submitted!(mail)
mail_key = extract_mail_key(mail)
handler = Handler.for(mail, mail_key)
......@@ -91,6 +90,16 @@ module Gitlab
break key if key
end
end
def ignore_auto_submitted!(mail)
# Mail::Header#[] is case-insensitive
auto_submitted = mail.header['Auto-Submitted']&.value
# Mail::Field#value would strip leading and trailing whitespace
raise AutoGeneratedEmailError if
# See also https://tools.ietf.org/html/rfc3834
auto_submitted && auto_submitted != 'no'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment