From 9a19c0d9c44386bd51aeeefdf5896c55647d2361 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 25 Jun 2013 14:05:14 -0400 Subject: [PATCH] Fix for multiple paragraph emails with text em-dashes in them (--). --- Gemfile | 2 +- Gemfile.lock | 9 ++++-- spec/components/email/receiver_spec.rb | 17 +++++++++++ spec/fixtures/emails/paragraphs.eml | 42 ++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/emails/paragraphs.eml diff --git a/Gemfile b/Gemfile index 454b161c242..d619c00710c 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'fog', require: false gem 'has_ip_address' gem 'hiredis' -gem 'email_reply_parser' +gem 'email_reply_parser', git: 'https://github.com/lawrencepit/email_reply_parser.git' # note: for image_optim to correctly work you need # sudo apt-get install -y advancecomp gifsicle jpegoptim libjpeg-progs optipng pngcrush diff --git a/Gemfile.lock b/Gemfile.lock index a5a7f415de0..056c6fe0506 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,6 +53,12 @@ GIT multi_json omniauth (~> 1.0) +GIT + remote: https://github.com/lawrencepit/email_reply_parser.git + revision: 67408dfb1b99fb8d5f145f782b9e22d1851a8e5a + specs: + email_reply_parser (0.6) + GIT remote: https://github.com/rails-api/active_model_serializers.git revision: fe84e0ad5268f1439123fd9a1f9fd12e25a54cd3 @@ -158,7 +164,6 @@ GEM diffy (2.1.4) em-redis (0.3.0) eventmachine - email_reply_parser (0.5.3) ember-rails (0.10.0) active_model_serializers barber @@ -470,7 +475,7 @@ DEPENDENCIES discourse_emoji! discourse_plugin! em-redis - email_reply_parser + email_reply_parser! ember-rails ember-source (= 1.0.0.rc5) eventmachine diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index ab6758b441f..39b32fa827e 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -40,6 +40,23 @@ stripped from my reply?") end end + describe "multiple paragraphs" do + let(:paragraphs) { File.read("#{Rails.root}/spec/fixtures/emails/paragraphs.eml") } + let(:receiver) { Email::Receiver.new(paragraphs) } + + it "does something" do + receiver.process + expect(receiver.body).to eq( +"Is there any reason the *old* candy can't be be kept in silos while the new candy +is imported into *new* silos? + +The thing about candy is it stays delicious for a long time -- we can just keep +it there without worrying about it too much, imo. + +Thanks for listening.") + end + end + describe "with a valid email" do let(:reply_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" } let(:valid_reply) { File.read("#{Rails.root}/spec/fixtures/emails/valid_reply.eml") } diff --git a/spec/fixtures/emails/paragraphs.eml b/spec/fixtures/emails/paragraphs.eml new file mode 100644 index 00000000000..c349724185c --- /dev/null +++ b/spec/fixtures/emails/paragraphs.eml @@ -0,0 +1,42 @@ +Return-Path: +Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400 +Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 13 Jun 2013 17:03:50 -0400 +Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for ; Thu, 13 Jun 2013 14:03:48 -0700 +Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700 +Date: Thu, 13 Jun 2013 17:03:48 -0400 +From: Jake the Dog +To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo +Message-ID: +Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' +Mime-Version: 1.0 +Content-Type: text/plain; + charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Sieve: CMU Sieve 2.2 +X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu, + 13 Jun 2013 14:03:48 -0700 (PDT) +X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1 + +Is there any reason the *old* candy can't be be kept in silos while the new candy +is imported into *new* silos? + +The thing about candy is it stays delicious for a long time -- we can just keep +it there without worrying about it too much, imo. + +Thanks for listening. + +On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta + wrote: +> +> +> +> eviltrout posted in 'Adventure Time Sux' on Discourse Meta: +> +> --- +> hey guys everyone knows adventure time sucks! +> +> --- +> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3 +> +> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences). +> \ No newline at end of file