diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-01-17 11:01:45 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-01-22 12:01:22 +0000 |
commit | 6dc2c6fde65b6f521e5b9e18b0cbeb33a7e156c5 (patch) | |
tree | 9b3606dcfcbbe1a1437ad9d9b7ab95efe547d3a2 | |
parent | a6b40e039aca35e011e9e106f6a791ffa4b555db (diff) |
Handle gmail-style quoting from the HTML part of a mail.
We already handled this type of quoting when coming directly from a text
part of a mail, but when we choose the HTML part as the main part and
then convert it to text, the 'On [date] <email> person said:' part can
get split over two lines.
-rw-r--r-- | app/models/incoming_message.rb | 4 | ||||
-rw-r--r-- | spec/fixtures/files/email-folding-example-11.txt | 45 | ||||
-rw-r--r-- | spec/fixtures/files/email-folding-example-11.txt.expected | 8 |
3 files changed, 57 insertions, 0 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index bcf0b6ec9..59e61952e 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -385,6 +385,10 @@ class IncomingMessage < ActiveRecord::Base multiline_original_message = '(' + '''>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>''' + ')' text.gsub!(/^(#{multiline_original_message}\n.*)$/m, replacement) + # On Thu, Nov 28, 2013 at 9:08 AM, A User + # <[1]request-7-skm40s2ls@xxx.xxxx> wrote: + text.gsub!(/^( On [^\n]+\n\s*\<[^>\n]+\> (wrote|said):\s*\n.*)$/m, replacement) + # Single line sections text.gsub!(/^(>.*\n)/, replacement) text.gsub!(/^(On .+ (wrote|said):\n)/, replacement) diff --git a/spec/fixtures/files/email-folding-example-11.txt b/spec/fixtures/files/email-folding-example-11.txt new file mode 100644 index 000000000..635d7aa4f --- /dev/null +++ b/spec/fixtures/files/email-folding-example-11.txt @@ -0,0 +1,45 @@ + Hello Example, + + This is a reply to your test request Nov 28. + + Regards. + + On Thu, Nov 28, 2013 at 9:08 AM, Example User + <[1]request-x-xxx@xxx.com> wrote: + + Dear Test Authority, + + This is the request body. + + Yours faithfully, + + Example User + + ------------------------------------------------------------------- + + Please use this email address for all replies to this request: + [2]request-x-xxx@xxx.com + + Is [3]testauthority@example.com the wrong address for Freedom of + Information requests to AYG Test Authority? If so, please contact us + using this form: + [4]http://example.com/help/contact + + Disclaimer: This message and any reply that you make will be published + on the internet. Our privacy and copyright policies: + [5]http://example.com/help/officers + + If you find this service useful as an FOI officer, please ask your web + manager to link to us from your organisation's FOI page. + + ------------------------------------------------------------------- + +References + + Visible links + 1. mailto:request-x-xxx@xxx.com + 2. mailto:request-x-xxx@xxx.com + 3. mailto:testauthority@example.com + 4. http://example.com/help/contact + 5. http://example.com/help/officers + diff --git a/spec/fixtures/files/email-folding-example-11.txt.expected b/spec/fixtures/files/email-folding-example-11.txt.expected new file mode 100644 index 000000000..e336062c7 --- /dev/null +++ b/spec/fixtures/files/email-folding-example-11.txt.expected @@ -0,0 +1,8 @@ + Hello Example, + + This is a reply to your test request Nov 28. + + Regards. + + +FOLDED_QUOTED_SECTION |