Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: mailread.rb
# The Mail class represents an internet mail message (as per RFC822, RFC2822)
[0] Fix | Delete
# with headers and a body.
[1] Fix | Delete
class Mail
[2] Fix | Delete
[3] Fix | Delete
# Create a new Mail where +f+ is either a stream which responds to gets(),
[4] Fix | Delete
# or a path to a file. If +f+ is a path it will be opened.
[5] Fix | Delete
#
[6] Fix | Delete
# The whole message is read so it can be made available through the #header,
[7] Fix | Delete
# #[] and #body methods.
[8] Fix | Delete
#
[9] Fix | Delete
# The "From " line is ignored if the mail is in mbox format.
[10] Fix | Delete
def initialize(f)
[11] Fix | Delete
unless defined? f.gets
[12] Fix | Delete
f = open(f, "r")
[13] Fix | Delete
opened = true
[14] Fix | Delete
end
[15] Fix | Delete
[16] Fix | Delete
@header = {}
[17] Fix | Delete
@body = []
[18] Fix | Delete
begin
[19] Fix | Delete
while line = f.gets()
[20] Fix | Delete
line.chop!
[21] Fix | Delete
next if /^From /=~line # skip From-line
[22] Fix | Delete
break if /^$/=~line # end of header
[23] Fix | Delete
[24] Fix | Delete
if /^(\S+?):\s*(.*)/=~line
[25] Fix | Delete
(attr = $1).capitalize!
[26] Fix | Delete
@header[attr] = $2
[27] Fix | Delete
elsif attr
[28] Fix | Delete
line.sub!(/^\s*/, '')
[29] Fix | Delete
@header[attr] += "\n" + line
[30] Fix | Delete
end
[31] Fix | Delete
end
[32] Fix | Delete
[33] Fix | Delete
return unless line
[34] Fix | Delete
[35] Fix | Delete
while line = f.gets()
[36] Fix | Delete
break if /^From /=~line
[37] Fix | Delete
@body.push(line)
[38] Fix | Delete
end
[39] Fix | Delete
ensure
[40] Fix | Delete
f.close if opened
[41] Fix | Delete
end
[42] Fix | Delete
end
[43] Fix | Delete
[44] Fix | Delete
# Return the headers as a Hash.
[45] Fix | Delete
def header
[46] Fix | Delete
return @header
[47] Fix | Delete
end
[48] Fix | Delete
[49] Fix | Delete
# Return the message body as an Array of lines
[50] Fix | Delete
def body
[51] Fix | Delete
return @body
[52] Fix | Delete
end
[53] Fix | Delete
[54] Fix | Delete
# Return the header corresponding to +field+.
[55] Fix | Delete
#
[56] Fix | Delete
# Matching is case-insensitive.
[57] Fix | Delete
def [](field)
[58] Fix | Delete
@header[field.capitalize]
[59] Fix | Delete
end
[60] Fix | Delete
end
[61] Fix | Delete
[62] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function