Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8038: body_charset.patch

File body_charset.patch, 1.3 kB (added by Theory, 1 year ago)

Use default charset when no content type specified

  • test/mail_service_test.rb

    old new  
    803803  def test_multipart_with_template_path_with_dots 
    804804    mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient) 
    805805    assert_equal 2, mail.parts.length 
     806    assert_equal 'text/plain', mail.parts[0].content_type 
     807    assert_equal 'utf-8', mail.parts[0].charset 
    806808  end 
    807809 
    808810  def test_custom_content_type_attributes 
  • lib/action_mailer/part_container.rb

    old new  
    4141    private 
    4242     
    4343      def parse_content_type(defaults=nil) 
    44         return [defaults && defaults.content_type, {}] if content_type.blank? 
     44        if content_type.blank? 
     45          return defaults                                                ? 
     46            [ defaults.content_type, { 'charset' => defaults.charset } ] : 
     47            [ nil, {} ] 
     48        end 
    4549        ctype, *attrs = content_type.split(/;\s*/) 
    4650        attrs = attrs.inject({}) { |h,s| k,v = s.split(/=/, 2); h[k] = v; h } 
    4751        [ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]