开发者

SMTP: \r\n\r (without second \n) as double newline

开发者 https://www.devze.com 2023-03-09 05:28 出处:网络
I have SMTP parser that works mostly fine. T开发者_开发问答here is a problem when receiving traffic from third party software that sends double newlines as \"\\r\\n\\r\" (without the second \"\\n\").

I have SMTP parser that works mostly fine. T开发者_开发问答here is a problem when receiving traffic from third party software that sends double newlines as "\r\n\r" (without the second "\n"). Currently such connections are terminated as non-compliant SMTP. Can somebody explain what exactly RFC says about such "funny" double newlines? Can I asume that software that sends data like that is doing something really wrong?


RFC2821. Section 2.3.7:

SMTP commands and, unless altered by a service extension, message
data, are transmitted in "lines". Lines consist of zero or more data
characters terminated by the sequence ASCII character "CR" (hex value 0D) followed immediately by ASCII character "LF" (hex value 0A).

http://www.ietf.org/rfc/rfc2821.txt

--Dave


Various operating systems have various representations for Newline characters. Check the instructions here on newline characters.. By the way its a common practice among programmers to use both the \n and \r together to prevent any conflicts on the system. You need to check which newline character is supported by your system. If its \r then you are getting both the required characters. But if its \n, then the error lies with the sender.

0

精彩评论

暂无评论...
验证码 换一张
取 消