Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-20 04:00:13 +0300
committerDouwe Maan <douwe@gitlab.com>2015-08-20 04:00:13 +0300
commit83081f167397c6c325a4f8c604191e766b2c3d3b (patch)
treeda06920b4cb257a24f74429088bfd0474c7efaa1 /lib
parent19a049ece9e350623e3adb141298c00344cab02d (diff)
Start on tests.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/email_receiver.rb37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/gitlab/email_receiver.rb b/lib/gitlab/email_receiver.rb
index a0b4ff87e02..3c1f346c0cf 100644
--- a/lib/gitlab/email_receiver.rb
+++ b/lib/gitlab/email_receiver.rb
@@ -62,6 +62,21 @@ module Gitlab
end
end
+ def parse_body(message)
+ body = select_body(message)
+
+ encoding = body.encoding
+ raise EmptyEmailError if body.strip.blank?
+
+ body = discourse_email_trimmer(body)
+ raise EmptyEmailError if body.strip.blank?
+
+ body = EmailReplyParser.parse_reply(body)
+ raise EmptyEmailError if body.strip.blank?
+
+ body.force_encoding(encoding).encode("UTF-8")
+ end
+
private
def reply_key
@@ -80,21 +95,6 @@ module Gitlab
SentNotification.for(reply_key)
end
- def parse_body(message)
- body = select_body(message)
-
- encoding = body.encoding
- raise EmptyEmailError if body.strip.blank?
-
- body = discourse_email_trimmer(body)
- raise EmptyEmailError if body.strip.blank?
-
- body = EmailReplyParser.parse_reply(body)
- raise EmptyEmailError if body.strip.blank?
-
- body.force_encoding(encoding).encode("UTF-8")
- end
-
def select_body(message)
html = nil
text = nil
@@ -144,10 +144,9 @@ module Gitlab
range_end = 0
lines.each_with_index do |l, idx|
- break if l =~ /\A\s*\-{3,80}\s*\z/ ||
- # This one might be controversial but so many reply lines have years, times and end with a colon.
- # Let's try it and see how well it works.
- (l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) ||
+ # This one might be controversial but so many reply lines have years, times and end with a colon.
+ # Let's try it and see how well it works.
+ break if (l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) ||
(l =~ /On \w+ \d+,? \d+,?.*wrote:/)
# Headers on subsequent lines