Skip to content

Commit b7f22bf

Browse files
committed
Merge pull request #253 from oreoshake/regression-email-reply-pipeline
Regression in EmailReplyPipeline: unfiltered content is being ommitted
2 parents 336ec80 + 514a221 commit b7f22bf

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/html/pipeline/email_reply_filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def call
4949
if fragment.quoted?
5050
if context[:hide_quoted_email_addresses]
5151
pieces.map! do |piece|
52-
piece.gsub!(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN)
52+
piece.gsub(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN)
5353
end
5454
end
5555
pieces.unshift EMAIL_QUOTED_HEADER

test/html/pipeline/email_reply_filter_test.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,38 @@ def test_hides_email_addresses_when_configured
2929
refute_match %r([email protected]), doc
3030
refute_match %r([email protected]), doc
3131
end
32+
33+
def test_preserves_non_email_content_while_filtering
34+
str = <<-EMAIL
35+
> Thank you! I have some thoughts on this pull request.
36+
>
37+
> * acme provides cmake and a wrapper for it. Please use '$(TARGET)-cmake' instead of cmake -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' -DCMAKE_BUILD_TYPE=Release.
38+
39+
Okay -- I'm afraid I just blindly copied the eigen3.mk file, since that's a library I'm familiar with :-)
40+
41+
> * Do you need -DCMAKE_SYSTEM_PROCESSOR=x86?
42+
43+
Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it's not being built on ARM.
44+
45+
--
46+
Boaty McBoatface | http://example.org
47+
EMAIL
48+
49+
filter = EmailReplyFilter.new(str, :hide_quoted_email_addresses => true)
50+
doc = filter.call.to_s
51+
52+
expected = <<-EXPECTED
53+
<div class="email-quoted-reply"> Thank you! I have some thoughts on this pull request.
54+
55+
* acme provides cmake and a wrapper for it. Please use &#39;$(TARGET)-cmake&#39; instead of cmake -DCMAKE_TOOLCHAIN_FILE=&#39;$(CMAKE_TOOLCHAIN_FILE)&#39; -DCMAKE_BUILD_TYPE=Release.</div>
56+
<div class="email-fragment">Okay -- I&#39;m afraid I just blindly copied the eigen3.mk file, since that&#39;s a library I&#39;m familiar with :-)</div>
57+
<div class="email-quoted-reply"> * Do you need -DCMAKE_SYSTEM_PROCESSOR=x86?</div>
58+
<div class="email-fragment">Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it&#39;s not being built on ARM.</div>
59+
<span class="email-hidden-toggle"><a href="#">&hellip;</a></span><div class="email-hidden-reply" style="display:none"><div class="email-signature-reply">--
60+
Boaty McBoatface | http:&#47;&#47;example.org</div>
61+
</div>
62+
EXPECTED
63+
64+
assert_equal(expected.chomp, doc)
65+
end
3266
end

0 commit comments

Comments
 (0)