diff --git a/lib/html/pipeline/email_reply_filter.rb b/lib/html/pipeline/email_reply_filter.rb index 9cdb4029..02bbb5cd 100644 --- a/lib/html/pipeline/email_reply_filter.rb +++ b/lib/html/pipeline/email_reply_filter.rb @@ -49,7 +49,7 @@ def call if fragment.quoted? if context[:hide_quoted_email_addresses] pieces.map! do |piece| - piece.gsub!(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN) + piece.gsub(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN) end end pieces.unshift EMAIL_QUOTED_HEADER diff --git a/test/html/pipeline/email_reply_filter_test.rb b/test/html/pipeline/email_reply_filter_test.rb index 29582b32..f603c2c2 100644 --- a/test/html/pipeline/email_reply_filter_test.rb +++ b/test/html/pipeline/email_reply_filter_test.rb @@ -29,4 +29,38 @@ def test_hides_email_addresses_when_configured refute_match %r(boatymcboatface@example.com), doc refute_match %r(alreadyleaked@example.com), doc end + + def test_preserves_non_email_content_while_filtering + str = <<-EMAIL +> Thank you! I have some thoughts on this pull request. +> +> * 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. + +Okay -- I'm afraid I just blindly copied the eigen3.mk file, since that's a library I'm familiar with :-) + +> * Do you need -DCMAKE_SYSTEM_PROCESSOR=x86? + +Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it's not being built on ARM. + +-- +Boaty McBoatface | http://example.org +EMAIL + + filter = EmailReplyFilter.new(str, :hide_quoted_email_addresses => true) + doc = filter.call.to_s + + expected = <<-EXPECTED +
Thank you! I have some thoughts on this pull request. + + * 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.
+
Okay -- I'm afraid I just blindly copied the eigen3.mk file, since that's a library I'm familiar with :-)
+
* Do you need -DCMAKE_SYSTEM_PROCESSOR=x86?
+
Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it's not being built on ARM.
+ +EXPECTED + + assert_equal(expected.chomp, doc) + end end