summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-30 12:10:59 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-30 12:10:59 +0000
commit1b5f534487e25b7a34b69247261a69ed6dc6d413 (patch)
treed1b25f26b1016ebe169d6c616bca6cdb7c31a7d7 /lib
parent4757e396d2f8d8f39807cee32ef569e70dea9b15 (diff)
merge revision(s) 55324,55325: [Backport #13651]
* lib/net/smtp.rb (getok, get_response): raise an ArgumentError when CR or LF is included in a line, because they are not allowed in RFC5321. RFC5321. Thanks, Jeremy Daer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/smtp.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index d634274c3e..78f2181d2a 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -926,7 +926,15 @@ module Net
private
+ def validate_line(line)
+ # A bare CR or LF is not allowed in RFC5321.
+ if /[\r\n]/ =~ line
+ raise ArgumentError, "A line must not contain CR or LF"
+ end
+ end
+
def getok(reqline)
+ validate_line reqline
res = critical {
@socket.writeline reqline
recv_response()
@@ -936,6 +944,7 @@ module Net
end
def get_response(reqline)
+ validate_line reqline
@socket.writeline reqline
recv_response()
end