diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-06-25 10:02:17 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-06-25 13:15:55 +0100 |
commit | 68a306b56ce328bd4848adf6e2ab26feab8853f2 (patch) | |
tree | f80e4df5b2c099fef33f7b3edc6b0301f8648fce | |
parent | 6e03858dc7c909fb9446c3aaf6c6bc6d17604585 (diff) |
Handle non-UTF8 encoding in ruby 1.9 and aboveadd-widget-hotfixed
-rwxr-xr-x | script/handle-mail-replies.rb | 2 | ||||
-rw-r--r-- | spec/fixtures/files/russian.email | 40 | ||||
-rw-r--r-- | spec/script/handle-mail-replies_spec.rb | 19 |
3 files changed, 56 insertions, 5 deletions
diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb index cbff03acb..29f618154 100755 --- a/script/handle-mail-replies.rb +++ b/script/handle-mail-replies.rb @@ -168,7 +168,7 @@ def is_oof?(message) end def forward_on(raw_message) - IO.popen("/usr/sbin/sendmail -i #{AlaveteliConfiguration::forward_nonbounce_responses_to}", "w") do |f| + IO.popen("/usr/sbin/sendmail -i #{AlaveteliConfiguration::forward_nonbounce_responses_to}", "wb") do |f| f.write(raw_message); f.close; end diff --git a/spec/fixtures/files/russian.email b/spec/fixtures/files/russian.email new file mode 100644 index 000000000..6e33b1b46 --- /dev/null +++ b/spec/fixtures/files/russian.email @@ -0,0 +1,40 @@ +Message-ID: <558BB884.2010504@whatdotheyknow.com> +Date: Thu, 25 Jun 2015 09:15:00 +0100 +From: xx <xx@xx.com> +Reply-To: xx@xx.com +User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 +MIME-Version: 1.0 +To: test@example.com <test@example.com> +CC: xx <xx@xx.com> +Subject: Re: =?UTF-8?B?0JLQsNGIINGB0LDQudGC?= +References: <558bb6f371205_72da364cd0c4353@titan.mail> +In-Reply-To: <558bb6f371205_72da364cd0c4353@titan.mail> +Content-Type: text/plain; charset=utf-8; format=flowed +Content-Transfer-Encoding: 8bit + +ãòðöðõüðѠÞúÑÂðýð ßþ÷ôýÑÂúþòð, + +ÑÂÿðÑÂøñþ ÷ð òðшõ ÿøÑÂьüþ. ÞтýþÑÂøтõûьýþ òðшõóþ òþÿрþÑÂð, ò à þÑÂÑÂøø õÑÂть ÑÂðùт +à þÑÂÞтòõт - http://rosotvet.ru/ + +à þÑÂÞтòõт ýõúþüüõрчõÑÂúøù ÑÂõрòøѠôûѠþтÿрðòúø ÷ðÿрþÑÂþò ýð ÿþûучõýøõ +øýфþрüðцøø þ ôõÑÂтõûьýþÑÂтø þрóðýþò òûðÑÂтø. Ã’Ñ‹ ÷ðÿþûýÑÂõтõ фþрüу, уúð÷ыòðÑÂ, +úðúðѠøýфþрüðцøѠòðѠøýтõрõÑÂуõт ø îрøÑÂты ÿрþõúтð þфþрüÃȄÂют òðшу ÷ðÑÂòúу +úðú юрøôøчõÑÂúø óрðüþтýыù ÷ðÿрþÑÂ, òыñøрðѠрõûõòðýтýыù þрóðý òûðÑÂтø. Þýø +þтÿрðòÃȄÂют ÷ðÿрþѠþт ýðшõóþ øüõýø ÿþтþüу, чтþ þýø áÜØ. áõùчðѠò ÑÂðùтõ +õÑÂть 370 ÷ðÿрþÑÂþò ø 254 þтòõтþò. + +á уòðöõýøõü, + +Ã¥õûõýь ÚрþѠ+--------- +Helen - WhatDoTheyKnow.com volunteer. + + +On 25/06/2015 09:08, ÞúÑÂðýð ßþ÷ôýÑÂúþòð wrote: +> B рþÑÂÑÂøø õÑÂть ÿþôþñýыù ÑÂðùт? +> +> --------------------------------------------------------------------- +> Message sent using WhatDoTheyKnow contact form, +> not logged in --------------------------------------------------------------------- + diff --git a/spec/script/handle-mail-replies_spec.rb b/spec/script/handle-mail-replies_spec.rb index 90a8de27c..669fc0c10 100644 --- a/spec/script/handle-mail-replies_spec.rb +++ b/spec/script/handle-mail-replies_spec.rb @@ -12,10 +12,21 @@ def mail_reply_test(email_filename) end describe "When filtering" do - it "should not fail when not in test mode" do - xc = ExternalCommand.new("script/handle-mail-replies") - xc.run(load_file_fixture("track-response-exim-bounce.email")) - xc.err.should == "" + + + describe "when not in test mode" do + + it "should not fail handling a bounce mail" do + xc = ExternalCommand.new("script/handle-mail-replies") + xc.run(load_file_fixture("track-response-exim-bounce.email")) + xc.err.should == "" + end + + it 'should not fail handling a UTF8 encoded mail' do + xc = ExternalCommand.new("script/handle-mail-replies") + xc.run(load_file_fixture("russian.email")) + xc.err.should == "" + end end it "should detect an Exim bounce" do |