lib/mail/header.rb in mail-2.7.0.rc1 vs lib/mail/header.rb in mail-2.7.0.rc2

- old
+ new

@@ -48,11 +48,11 @@ # no automatic processing of that field will happen. If you find one of # 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) @charset = charset - self.raw_source = ::Mail::Utilities.to_crlf(header_text).lstrip + self.raw_source = header_text split_header if header_text end def initialize_copy(original) super @@ -91,18 +91,19 @@ # # h = Header.new # h.fields = ['From: mikel@me.com', 'To: bob@you.com'] def fields=(unfolded_fields) @fields = Mail::FieldList.new - warn "Warning: more than #{self.class.maximum_amount} header fields only using the first #{self.class.maximum_amount}" if unfolded_fields.length > self.class.maximum_amount + Kernel.warn "WARNING: More than #{self.class.maximum_amount} header fields; only using the first #{self.class.maximum_amount} and ignoring the rest" if unfolded_fields.length > self.class.maximum_amount unfolded_fields[0..(self.class.maximum_amount-1)].each do |field| - field = Field.new(field, nil, charset) - if limited_field?(field.name) && (selected = select_field_for(field.name)) && selected.any? - selected.first.update(field.name, field.value) - else - @fields << field + if field = Field.parse(field, charset) + if limited_field?(field.name) && (selected = select_field_for(field.name)) && selected.any? + selected.first.update(field.name, field.value) + else + @fields << field + end end end end @@ -247,10 +248,10 @@ end private def raw_source=(val) - @raw_source = val + @raw_source = ::Mail::Utilities.to_crlf(val).lstrip end # Splits an unfolded and line break cleaned header into individual field # strings. def split_header