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

Changeset 964

Show
Ignore:
Timestamp:
03/21/05 12:10:47 (4 years ago)
Author:
david
Message:

Made the unquoted subject and body the default

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/facade.rb

    r4 r964  
    262262      end 
    263263    end 
     264    alias quoted_subject subject 
    264265 
    265266    def subject=( str ) 
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/mail.rb

    r916 r964  
    323323    end 
    324324 
    325     def body 
     325    def quoted_body 
    326326      parse_body 
    327327      @body_port.ropen {|f| 
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb

    r919 r964  
    44module TMail 
    55  class Mail 
    6     def unquoted_subject(to_charset = 'utf-8') 
    7       Unquoter.unquote_and_convert_to(subject || "", to_charset) 
     6    def subject(to_charset = 'utf-8') 
     7      Unquoter.unquote_and_convert_to(quoted_subject || "", to_charset) 
    88    end 
    99 
    1010    def unquoted_body(to_charset = 'utf-8') 
    11       Unquoter.unquote_and_convert_to(body || "", to_charset, header["content-type"]["charset"]) 
     11      Unquoter.unquote_and_convert_to(quoted_body || "", to_charset, header["content-type"]["charset"]) 
    1212    end 
    1313 
    14     def unquoted_body_with_all_parts(to_charset = 'utf-9', &block) 
     14    def body(to_charset = 'utf-8', &block) 
    1515      attachment_presenter = block || Proc.new { |file_name| "Attachment: #{file_name}\n" } 
    1616       
     
    1818        parts.collect { |part|  
    1919          part.header["content-type"].main_type == "text" ?  
    20             part.unquoted_body : attachment_presenter.call(part.header["content-type"].params["name"]) 
     20            part.unquoted_body(to_charset) : 
     21            attachment_presenter.call(part.header["content-type"].params["name"]) 
    2122        }.join 
    2223      else 
    23         unquoted_body 
     24        unquoted_body(to_charset) 
    2425      end 
    2526    end 
  • trunk/actionmailer/README

    r941 r964  
    6767      page = Page.find_by_address(email.to.first) 
    6868      page.emails.create( 
    69         :subject => email.unquoted_subject, :body => email.unquoted_body_with_all_parts 
     69        :subject => email.subject, :body => email.body 
    7070      ) 
    7171 
     
    7373        for attachment in email.attachments 
    7474          page.attachments.create({  
    75             :file => attachment, :description => email.unquoted_subject 
     75            :file => attachment, :description => email.subject 
    7676          }) 
    7777        end 
  • trunk/actionmailer/test/mail_service_test.rb

    r699 r964  
    213213  end 
    214214 
     215  def test_unquote_subject 
     216    msg = <<EOF 
     217From: me@example.com 
     218Subject: =?utf-8?Q?testing_testing_=D6=A4?= 
     219Content-Type: text/plain; charset=iso-8859-1 
     220 
     221This_is_a_test 
     2222 + 2 =3D 4 
     223EOF 
     224    mail = TMail::Mail.parse(msg) 
     225    assert_equal "testing testing \326\244", mail.subject 
     226    assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject 
     227    assert_equal "This is a test\n2 + 2 = 4\n", mail.body 
     228    assert_equal "This_is_a_test\n2 + 2 =3D 4\n", mail.quoted_body 
     229  end 
     230 
    215231end 
    216232