try to strip out attributed text from incoming e-mails
This commit is contained in:
parent
b75468a2c9
commit
f9778044f0
|
@ -102,8 +102,9 @@ class EmailParser
|
|||
# try to remove sig lines
|
||||
@body.gsub!(/^-- \n.+\z/m, "")
|
||||
|
||||
# TODO: try to strip out attribution line, followed by an optional blank
|
||||
# line, and then lines prefixed with >
|
||||
# try to strip out attribution line, followed by an optional blank line,
|
||||
# and then lines prefixed with >
|
||||
@body.gsub!(/^(On|on|at) .*\n\n?(>.*\n)+/, "")
|
||||
|
||||
@body.strip!
|
||||
end
|
||||
|
|
|
@ -19,6 +19,6 @@ On Sun, Feb 2, 2014 at 11:51 PM, blah <blah@lobste.rs> wrote:
|
|||
It hasn't decreased any measurable amount but since the traffic to
|
||||
the site is increasing a bit each week, it's hard to tell.
|
||||
|
||||
--
|
||||
this is my signature
|
||||
On Mon, Feb 3, 2014 at 3:36 PM, someone else wrote:
|
||||
> This is some terrible reply-on-top text
|
||||
|
||||
|
|
|
@ -58,4 +58,15 @@ describe EmailParser do
|
|||
parser.email.should_not == nil
|
||||
parser.body.should == "It hasn't decreased any measurable amount but since the traffic to\nthe site is increasing a bit each week, it's hard to tell."
|
||||
end
|
||||
|
||||
it "strips quoted lines with attribution" do
|
||||
parser = EmailParser.new(
|
||||
"user@example.com",
|
||||
Rails.application.shortname +
|
||||
"-#{@emailer.mailing_list_token}@example.org",
|
||||
@emails["4"])
|
||||
|
||||
parser.email.should_not == nil
|
||||
parser.body.should == "It hasn't decreased any measurable amount but since the traffic to\nthe site is increasing a bit each week, it's hard to tell."
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue