Skip to content

Instantly share code, notes, and snippets.

@saimonmoore
Created June 26, 2013 23:39
Show Gist options
  • Save saimonmoore/5872757 to your computer and use it in GitHub Desktop.
Save saimonmoore/5872757 to your computer and use it in GitHub Desktop.
Demonstrate Microsoft SMTPSVC mail header bug
# With invalid space between "Microsoft" and "SMTPSVC"
# Parses incorrectly
irb(main):001:0> Mail::Header.new( "Received: from LEXCV6.live.trust.xblt.nhs.uk ([12.10.5.27]) by lexcb1.live.trust.xblt.nhs.uk with Microsoft SMTPSVC(6.0.3790.4675); Fri, 26 Oct 2012 15:42:13 +0100" ).errors
=> [[Received, from LEXCV6.live.trust.xblt.nhs.uk ([12.10.5.27]) by lexcb1.live.trust.xblt.nhs.uk with Microsoft SMTPSVC(6.0.3790.4675); Fri, 26 Oct 2012 15:42:13 +0100, #<Mail::Field::ParseError: ReceivedElement can not parse |from LEXCV6.live.trust.xblt.nhs.uk ([12.10.5.27]) by lexcb1.live.trust.xblt.nhs.uk with Microsoft SMTPSVC(6.0.3790.4675); Fri, 26 Oct 2012 15:42:13 +0100|
Reason was: Expected one of
, (, <, ., ", !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, }, ~, [ at line 1, column 121 (byte 121) after from LEXCV6.live.trust.xblt.nhs.uk ([12.10.5.27]) by lexcb1.live.trust.xblt.nhs.uk with Microsoft SMTPSVC(6.0.3790.4675)
>]]
# Without invalid space between "Microsoft" and "SMTPSVC"
# Parses correctly
irb(main):002:0> Mail::Header.new( "Received: from LEXCV6.live.trust.xblt.nhs.uk ([12.10.5.27]) by lexcb1.live.trust.xblt.nhs.uk with MicrosoftSMTPSVC(6.0.3790.4675); Fri, 26 Oct 2012 15:42:13 +0100" ).errors
=> []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment