lib/mail/header.rb in mail-2.5.3 vs lib/mail/header.rb in mail-2.5.4
- old
+ new
@@ -48,11 +48,11 @@
# these cases, please make a patch and send it in, or at the least, send
# me the example so we can fix it.
def initialize(header_text = nil, charset = nil)
@errors = []
@charset = charset
- self.raw_source = header_text.to_crlf
+ self.raw_source = header_text.to_crlf.lstrip
split_header if header_text
end
# The preserved raw source of the header as you passed it in, untouched
# for your Regexing glory.
@@ -152,10 +152,13 @@
# h['X-Mail-SPAM'] # => ['15', '20', '10000']
# h['X-Mail-SPAM'] = nil
# h['X-Mail-SPAM'] # => nil
def []=(name, value)
name = dasherize(name)
+ if name.include?(':')
+ raise ArgumentError, "Header names may not contain a colon: #{name.inspect}"
+ end
fn = name.downcase
selected = select_field_for(fn)
case
# User wants to delete the field
@@ -196,9 +199,10 @@
content-transfer-encoding content-description
content-id content-disposition content-location]
def encoded
buffer = ''
+ buffer.force_encoding('us-ascii') if buffer.respond_to?(:force_encoding)
fields.each do |field|
buffer << field.encoded
end
buffer
end