aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-10-18 10:51:27 +0100
committerLouise Crow <louise.crow@gmail.com>2012-10-18 19:21:41 +0100
commit9d5af4d00c9e32a1dea163dfc8f5b57c53aea254 (patch)
tree0ae80295aca35e2b54d5384ca6bc3f840f501395
parenta902a8308fe05e9fd7a61aa8378aaf95729fcc88 (diff)
Convert request cited in comment to failing spec, update regex to make it pass (we now use the HTML parts of emails by preference, so there are some leading spaces.)
-rw-r--r--app/models/incoming_message.rb3
-rw-r--r--spec/fixtures/files/forward-quoting-example.email73
-rw-r--r--spec/models/incoming_message_spec.rb8
3 files changed, 82 insertions, 2 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 367909f57..0511d16b0 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -347,8 +347,7 @@ class IncomingMessage < ActiveRecord::Base
text.gsub!(/^\s?#{name}[^\n]+\n([^\n]+\n)?\s?Sent by:[^\n]+\n.*/ims, "\n\n" + replacement)
# Some other sort of forwarding quoting
- # http://www.whatdotheyknow.com/request/224/response/326
- text.gsub!(/^#{name}[^\n]+\n[0-9\/:\s]+\s+To\s+FOI requests at.*/ims, "\n\n" + replacement)
+ text.gsub!(/^\s?#{name}\s+To\s+FOI requests at.*/ims, "\n\n" + replacement)
# http://www.whatdotheyknow.com/request/how_do_the_pct_deal_with_retirin_33#incoming-930
# http://www.whatdotheyknow.com/request/229/response/809
diff --git a/spec/fixtures/files/forward-quoting-example.email b/spec/fixtures/files/forward-quoting-example.email
new file mode 100644
index 000000000..80b29c533
--- /dev/null
+++ b/spec/fixtures/files/forward-quoting-example.email
@@ -0,0 +1,73 @@
+From foi@example.com Thu Apr 17 16:45:16 2008
+Return-path: <foi@example.com>
+Envelope-to: request-xxx-xxxxx@whatdotheyknow.com
+Delivery-date: Thu, 17 Apr 2008 16:45:16 +0100
+To: FOI Person <EMAIL_TO>
+Subject: Re: Freedom of Information request
+MIME-Version: 1.0
+From: FOI Officer <foi@example.com>
+Date: Thu, 17 Apr 2008 16:44:53 +0100
+Content-Type: multipart/alternative;
+ boundary="=_alternative 0056816D8025742E_="
+
+This is a multipart message in MIME format.
+
+--=_alternative 0056816D8025742E_=
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+17/04/08
+
+Dear Mr Requester
+
+Some text.
+
+Bob Smith <request-xxx-xxxxx@whatdotheyknow.com>
+17/04/08 15:57
+
+To
+FOI requests <foi@example.com>
+cc
+
+Subject
+Freedom of Information request
+
+
+
+--=_alternative 0056816D8025742E_=
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+
+<br><font size=2 face="sans-serif">17/04/08</font>
+<br>
+<br><font size=2 face="sans-serif">Dear Mr Requester</font>
+<br>
+<br><font size=2 face="Arial"><b>Some text.</font>
+<br>
+<br>
+<br>
+<table width=100%>
+<tr valign=top>
+<td width=40%><font size=1 face="sans-serif"><b> Bob Smith &lt;request-xxx-xxxxx@whatdotheyknow.com&gt;</b>
+</font>
+<p><font size=1 face="sans-serif">17/04/08 15:57</font>
+<td width=59%>
+<table width=100%>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">To</font></div>
+<td valign=top><font size=1 face="sans-serif">FOI requests at &lt;foi@example.com&gt;</font>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">cc</font></div>
+<td valign=top>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">Subject</font></div>
+<td valign=top><font size=1 face="sans-serif">Freedom of Information request</font></table>
+<br>
+
+
+--=_alternative 0056816D8025742E_=--
+
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 69a5da0e9..fe1b36888 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -154,6 +154,14 @@ describe IncomingMessage, " folding quoted parts of emails" do
text.should == "\n\nFOLDED_QUOTED_SECTION"
end
+ it 'should fold an example of another kind of forward quoting' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('forward-quoting-example.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/)
+ end
+
+
end
describe IncomingMessage, " checking validity to reply to" do