html-pipeline 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e870978544619b3fa0227bbd4cc8c6e36949780d
4
- data.tar.gz: 99761bada479fffb0f7274db2518d909dd5e893a
3
+ metadata.gz: ed15fa4f3c355b07e08e89afa43a22255c991707
4
+ data.tar.gz: 0ae30d5bb58a6e147cabe6c4544d91924baa57ce
5
5
  SHA512:
6
- metadata.gz: 99901c855f115587bcda2679e6a4cc465fe0c2eb26002bc92ec6c24610e74e01924f71f58590680f8f440418d2761ce4be42445dd39866835f85067bbc26aa69
7
- data.tar.gz: 120582d65f9d33660acd0230324633a191931122d2e84c965d9d18332a4f9e6531d7ad04310f1f5711269fd8edeb75ce45e23b867e0d9a0582df933117c47cd8
6
+ metadata.gz: 9e288b4a1bacea79b17470dbbc5c87c681df180f32c944082670830a9c9fe61790c2e6e86ff0867e4398de10b7968d6bfe17e073261eb62dd1878b02dba7dbe9
7
+ data.tar.gz: 22009dc61f3647e40a23bff646020dfae75fc9acc1aee68d24d29abf23045365c630b8f95a90b0a71daa3656379ba6ac35e9bb76963ad9ac900cb2080b46ad36
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.4.0
4
+
5
+ * Optionally filter email addresses [#247](https://github.com/jch/html-pipeline/pull/247)
6
+
3
7
  ## 2.3.0
4
8
 
5
9
  * Add option to pass in an anchor icon, instead of using octicons [#244](https://github.com/jch/html-pipeline/pull/244)
@@ -27,6 +27,8 @@ module HTML
27
27
  EMAIL_SIGNATURE_HEADER = %(<div class="email-signature-reply">).freeze
28
28
  EMAIL_FRAGMENT_HEADER = %(<div class="email-fragment">).freeze
29
29
  EMAIL_HEADER_END = "</div>".freeze
30
+ EMAIL_REGEX = /[^@\s.][^@\s]*@\[?[a-z0-9.-]+\]?/
31
+ HIDDEN_EMAIL_PATTERN = "***@***.***"
30
32
 
31
33
  # Scans an email body to determine which bits are quoted and which should
32
34
  # be hidden. EmailReplyParser is used to split the comment into an Array
@@ -45,6 +47,11 @@ module HTML
45
47
  paragraphs = EmailReplyParser.read(text.dup).fragments.map do |fragment|
46
48
  pieces = [escape_html(fragment.to_s.strip).gsub(/^\s*(>|&gt;)/, '')]
47
49
  if fragment.quoted?
50
+ if context[:hide_quoted_email_addresses]
51
+ pieces.map! do |piece|
52
+ piece.gsub!(EMAIL_REGEX, HIDDEN_EMAIL_PATTERN)
53
+ end
54
+ end
48
55
  pieces.unshift EMAIL_QUOTED_HEADER
49
56
  pieces << EMAIL_HEADER_END
50
57
  elsif fragment.signature?
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "2.3.0"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
@@ -0,0 +1,32 @@
1
+ require "test_helper"
2
+
3
+ EmailReplyFilter = HTML::Pipeline::EmailReplyFilter
4
+
5
+ class HTML::Pipeline::EmailReplyFilterTest < Minitest::Test
6
+ def setup
7
+ @body = <<-EMAIL
8
+ Hey, don't send email addresses in comments. They aren't filtered.
9
+
10
+ > On Mar 5, 2016, at 08:05, Boaty McBoatface <boatymcboatface@example.com> wrote:
11
+ >
12
+ > Sup. alreadyleaked@example.com
13
+ >
14
+ > —
15
+ > Reply to this email directly or view it on GitHub.
16
+ EMAIL
17
+ end
18
+
19
+ def test_doesnt_hide_by_default
20
+ filter = EmailReplyFilter.new(@body)
21
+ doc = filter.call.to_s
22
+ assert_match %r(alreadyleaked@example.com), doc
23
+ assert_match %r(boatymcboatface@example.com), doc
24
+ end
25
+
26
+ def test_hides_email_addresses_when_configured
27
+ filter = EmailReplyFilter.new(@body, :hide_quoted_email_addresses => true)
28
+ doc = filter.call.to_s
29
+ refute_match %r(boatymcboatface@example.com), doc
30
+ refute_match %r(alreadyleaked@example.com), doc
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-20 00:00:00.000000000 Z
12
+ date: 2016-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2'
35
- - - <
35
+ - - "<"
36
36
  - !ruby/object:Gem::Version
37
37
  version: '5'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2'
45
- - - <
45
+ - - "<"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5'
48
48
  description: GitHub HTML processing filters and utilities
@@ -53,8 +53,8 @@ executables: []
53
53
  extensions: []
54
54
  extra_rdoc_files: []
55
55
  files:
56
- - .gitignore
57
- - .travis.yml
56
+ - ".gitignore"
57
+ - ".travis.yml"
58
58
  - CHANGELOG.md
59
59
  - CONTRIBUTING.md
60
60
  - Gemfile
@@ -90,6 +90,7 @@ files:
90
90
  - test/html/pipeline/absolute_source_filter_test.rb
91
91
  - test/html/pipeline/autolink_filter_test.rb
92
92
  - test/html/pipeline/camo_filter_test.rb
93
+ - test/html/pipeline/email_reply_filter_test.rb
93
94
  - test/html/pipeline/emoji_filter_test.rb
94
95
  - test/html/pipeline/https_filter_test.rb
95
96
  - test/html/pipeline/image_filter_test.rb
@@ -118,17 +119,17 @@ require_paths:
118
119
  - lib
119
120
  required_ruby_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
- - - '>='
122
+ - - ">="
122
123
  - !ruby/object:Gem::Version
123
124
  version: '0'
124
125
  required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  requirements:
126
- - - '>='
127
+ - - ">="
127
128
  - !ruby/object:Gem::Version
128
129
  version: '0'
129
130
  requirements: []
130
131
  rubyforge_project:
131
- rubygems_version: 2.0.14
132
+ rubygems_version: 2.5.1
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: Helpers for processing content through a chain of filters
@@ -137,6 +138,7 @@ test_files:
137
138
  - test/html/pipeline/absolute_source_filter_test.rb
138
139
  - test/html/pipeline/autolink_filter_test.rb
139
140
  - test/html/pipeline/camo_filter_test.rb
141
+ - test/html/pipeline/email_reply_filter_test.rb
140
142
  - test/html/pipeline/emoji_filter_test.rb
141
143
  - test/html/pipeline/https_filter_test.rb
142
144
  - test/html/pipeline/image_filter_test.rb