sanitize_email 1.1.6 → 1.1.7

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: 64c390a96c6347527bd9d4b0833a65ad16e3a837
4
- data.tar.gz: 02b106a696439a87a0001370d25316d7df494340
3
+ metadata.gz: dad83c2fc389a4b7fc0c71bad51a426385cb7f3b
4
+ data.tar.gz: 381499e8ecdfa1e68e8dc6dcec6424a5f70cc692
5
5
  SHA512:
6
- metadata.gz: 8854adb0d44027a38fde49d390c1d9f1e43e149800ff0f87e67f110427f646ae355e18bf42880d1f5449f9df2c4b621ec707c1f5db8560a2f85041bdf5041906
7
- data.tar.gz: 2b13251443bf8ad2f63dd7e4bdb41d721e373842907e3d3913bd1b8f952eddd258ac66a447bee79c3d3cacbf0745cdbd593eb7e269b0fd84f6c69d8c92de7cce
6
+ metadata.gz: c19005b057992350619501523f542e55a62d7eca91f9fac6260989c831e204cc46b9f7be96e3856c44144e4cff086e283439598e9ec4e680cf4e0aeb30cedd4a
7
+ data.tar.gz: e22805701740b748658f462799b640e04b0ab13c8b4eaa0e62c38c56c2979a7e0697ef605f2daec810f644561d6a774523f430b24c0cce9403065d2b13b54063
data/.reek ADDED
@@ -0,0 +1,9 @@
1
+ # attr_accessor is, in many cases, better than @instance variables which fail silently on typos, IMO
2
+ Attribute:
3
+ enabled: false
4
+ # One line methods are awesome, but need to focus on bigger problems first. Will lower this number as the code improves.
5
+ TooManyStatements:
6
+ max_statements: 8
7
+ FeatureEnvy:
8
+ exclude:
9
+ - delivering_email
@@ -1,22 +1,22 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
- - 2.1.0
6
- - 2.1.5
7
- - jruby-19mode
8
- # - rbx-19mode
9
- # - ruby-head
4
+ - 2.1.7
5
+ - 2.2.3
10
6
  gemfile:
11
- - gemfiles/Gemfile.rails-3.0.x
12
- - gemfiles/Gemfile.rails-3.1.x
13
7
  - gemfiles/Gemfile.rails-3.2.x
14
8
  - gemfiles/Gemfile.rails-4.0.x
9
+ - gemfiles/Gemfile.rails-4.1.x
10
+ - gemfiles/Gemfile.rails-4.2.x
15
11
  matrix:
16
12
  exclude:
17
- - rvm: 1.8.7
18
- gemfile: gemfiles/Gemfile.rails-4.0.x
19
- - rvm: 1.9.2
20
- gemfile: gemfiles/Gemfile.rails-4.0.x
21
- - rvm: jruby-19mode
13
+ - rvm: 2.0.0
14
+ gemfile: gemfiles/Gemfile.rails-4.2.x
15
+ - rvm: 2.1.7
16
+ gemfile: gemfiles/Gemfile.rails-4.2.x
17
+ matrix:
18
+ include:
19
+ - rvm: 1.9.3
22
20
  gemfile: gemfiles/Gemfile.rails-3.0.x
21
+ - rvm: 1.9.3
22
+ gemfile: gemfiles/Gemfile.rails-3.1.x
@@ -1,3 +1,13 @@
1
+ HEAD
2
+
3
+ Version 1.1.7 - AUG.30.2015
4
+ * No API changes
5
+ * General improvement to the code base by Peter Boling
6
+ - small refactorings
7
+ - documentation
8
+ - setup reek properly
9
+ - Fixed travis build matrix, added latest Ruby and Rails, and bumped patch releases
10
+
1
11
  Version 1.1.6 - AUG.29.2015
2
12
  * spec run as default rake task & improve Rakefile syntax by Peter Boling
3
13
  * prevent direct configuration via `DEFAULTS` from working, as that is not the API by Peter Boling
data/README.md CHANGED
@@ -303,7 +303,7 @@ bundle exec rake test:all
303
303
  If the tests pass refresh the `reek` list:
304
304
 
305
305
  ```
306
- bundle exec rake reek > REEK
306
+ bundle exec reek > REEK
307
307
  ```
308
308
 
309
309
  Follow the instructions for "Contributing" below.
@@ -331,7 +331,7 @@ dependency on this gem using the [Pessimistic Version Constraint][pvc] with two
331
331
 
332
332
  For example:
333
333
 
334
- spec.add_dependency 'sanitize_email', '~> 1.0.8'
334
+ spec.add_dependency 'sanitize_email', '~> 1.1'
335
335
 
336
336
  ## References
337
337
 
@@ -343,7 +343,7 @@ For example:
343
343
  ## Legal
344
344
 
345
345
  * MIT License - See LICENSE file in this project
346
- * Copyright (c) 2008-2014 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
346
+ * Copyright (c) 2008-2015 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
347
347
  * Copyright (c) 2009 [John Trupiano](http://smartlogicsolutions.com/wiki/John_Trupiano) of [SmartLogic Solutions, LLC](http://www.smartlogicsolutions.com)
348
348
 
349
349
  [semver]: http://semver.org/
data/REEK CHANGED
@@ -1,48 +1,37 @@
1
- lib/sanitize_email.rb -- 3 warnings:
2
- SanitizeEmail#self.sanitary calls SanitizeEmail::Config.config twice (DuplicateMethodCall)
3
- SanitizeEmail#self.sanitary has approx 6 statements (TooManyStatements)
4
- SanitizeEmail::MissingBlockParameter has no descriptive comment (IrresponsibleModule)
5
- lib/sanitize_email/bleach.rb -- 5 warnings:
6
- SanitizeEmail::Bleach#delivering_email has approx 6 statements (TooManyStatements)
7
- SanitizeEmail::Bleach#delivering_email has the variable name 'o' (UncommunicativeVariableName)
8
- SanitizeEmail::Bleach#delivering_email refers to message more than self (FeatureEnvy)
9
- SanitizeEmail::Bleach#delivering_email refers to o more than self (FeatureEnvy)
10
- SanitizeEmail::Bleach#sanitize_engaged? has approx 6 statements (TooManyStatements)
11
- lib/sanitize_email/config.rb -- 4 warnings:
12
- SanitizeEmail::Config has no descriptive comment (IrresponsibleModule)
13
- SanitizeEmail::Config#self.configure calls @config[:force_sanitize] twice (DuplicateMethodCall)
14
- SanitizeEmail::Config#self.configure calls @config[:sanitized_recipients] twice (DuplicateMethodCall)
15
- SanitizeEmail::Config#self.configure has approx 7 statements (TooManyStatements)
16
- lib/sanitize_email/deprecation.rb -- 2 warnings:
17
- SanitizeEmail::Deprecation takes parameters [name, replacement] to 3 methods (DataClump)
18
- SanitizeEmail::Deprecation#deprecation is controlled by argument replacement (ControlParameter)
19
- lib/sanitize_email/engine.rb -- 1 warning:
20
- SanitizeEmail::Engine has no descriptive comment (IrresponsibleModule)
21
- lib/sanitize_email/mail_header_tools.rb -- 8 warnings:
22
- SanitizeEmail::MailHeaderTools#self.add_original_addresses_as_headers has the variable name 'k' (UncommunicativeVariableName)
23
- SanitizeEmail::MailHeaderTools#self.add_original_addresses_as_headers has the variable name 'v' (UncommunicativeVariableName)
24
- SanitizeEmail::MailHeaderTools#self.prepend_environment_to_subject calls Rails.env twice (DuplicateMethodCall)
25
- SanitizeEmail::MailHeaderTools#self.update_header calls (index + 1) twice (DuplicateMethodCall)
26
- SanitizeEmail::MailHeaderTools#self.update_header has the parameter name 'k' (UncommunicativeParameterName)
27
- SanitizeEmail::MailHeaderTools#self.update_header has the parameter name 'v' (UncommunicativeParameterName)
28
- SanitizeEmail::MailHeaderTools#self.update_header has the variable name 'a' (UncommunicativeVariableName)
29
- SanitizeEmail::MailHeaderTools#self.update_header is controlled by argument v (ControlParameter)
1
+ lib/sanitize_email/bleach.rb -- 1 warning:
2
+ [59]:SanitizeEmail::Bleach#sanitize_engaged? performs a nil-check (NilCheck)
3
+ lib/sanitize_email/config.rb -- 3 warnings:
4
+ [64, 72]:SanitizeEmail::Config#self.configure calls @config[:force_sanitize] 2 times (DuplicateMethodCall)
5
+ [58, 62]:SanitizeEmail::Config#self.configure calls @config[:sanitized_recipients] 2 times (DuplicateMethodCall)
6
+ [64]:SanitizeEmail::Config#self.configure performs a nil-check (NilCheck)
7
+ lib/sanitize_email/deprecation.rb -- 1 warning:
8
+ [18, 29, 40]:SanitizeEmail::Deprecation takes parameters [name, replacement] to 3 methods (DataClump)
9
+ lib/sanitize_email/mail_header_tools.rb -- 1 warning:
10
+ [41, 42]:SanitizeEmail::MailHeaderTools#self.prepend_custom_subject calls message.subject 2 times (DuplicateMethodCall)
30
11
  lib/sanitize_email/overridden_addresses.rb -- 7 warnings:
31
- SanitizeEmail::OverriddenAddresses has no descriptive comment (IrresponsibleModule)
32
- SanitizeEmail::OverriddenAddresses#inject_user_names contains iterators nested 2 deep (NestedIterators)
33
- SanitizeEmail::OverriddenAddresses#inject_user_names doesn't depend on instance state (UtilityFunction)
34
- SanitizeEmail::OverriddenAddresses#inject_user_names refers to real_recipient more than self (FeatureEnvy)
35
- SanitizeEmail::OverriddenAddresses#override_email has approx 10 statements (TooManyStatements)
36
- SanitizeEmail::OverriddenAddresses::MissingTo has no descriptive comment (IrresponsibleModule)
37
- SanitizeEmail::OverriddenAddresses::UnknownOverride has no descriptive comment (IrresponsibleModule)
38
- lib/sanitize_email/railtie.rb -- 1 warning:
39
- SanitizeEmail::Railtie has no descriptive comment (IrresponsibleModule)
40
- lib/sanitize_email/rspec_matchers.rb -- 2 warnings:
41
- SanitizeEmail::RspecMatchers#get_username doesn't depend on instance state (UtilityFunction)
42
- SanitizeEmail::RspecMatchers#get_username refers to email_message more than self (FeatureEnvy)
43
- lib/sanitize_email/test_helpers.rb -- 4 warnings:
44
- SanitizeEmail::TestHelpers takes parameters [mail_or_part, matcher, part] to 3 methods (DataClump)
45
- SanitizeEmail::TestHelpers#array_matching refers to mail_or_part more than self (FeatureEnvy)
46
- SanitizeEmail::TestHelpers#string_matching refers to mail_or_part more than self (FeatureEnvy)
47
- SanitizeEmail::TestHelpers::UnexpectedMailType has no descriptive comment (IrresponsibleModule)
48
- lib/sanitize_email/version.rb -- 0 warnings
12
+ [6]:SanitizeEmail::OverriddenAddresses has at least 8 instance variables (TooManyInstanceVariables)
13
+ [25, 26, 27, 28, 29]:SanitizeEmail::OverriddenAddresses#initialize calls SanitizeEmail::Config.config 5 times (DuplicateMethodCall)
14
+ [109]:SanitizeEmail::OverriddenAddresses#inject_user_names contains iterators nested 2 deep (NestedIterators)
15
+ [103]:SanitizeEmail::OverriddenAddresses#inject_user_names doesn't depend on instance state (UtilityFunction)
16
+ [105]:SanitizeEmail::OverriddenAddresses#inject_user_names performs a nil-check (NilCheck)
17
+ [56]:SanitizeEmail::OverriddenAddresses#override_email has approx 10 statements (TooManyStatements)
18
+ [125]:SanitizeEmail::OverriddenAddresses#sanitize_addresses is controlled by argument type (ControlParameter)
19
+ lib/sanitize_email/rspec_matchers.rb -- 1 warning:
20
+ [35]:SanitizeEmail::RspecMatchers#get_username doesn't depend on instance state (UtilityFunction)
21
+ lib/sanitize_email/test_helpers.rb -- 3 warnings:
22
+ [11, 15, 28, 33]:SanitizeEmail::TestHelpers takes parameters [mail_or_part, matcher, part] to 4 methods (DataClump)
23
+ [29, 29]:SanitizeEmail::TestHelpers#array_matching refers to mail_or_part more than self (FeatureEnvy)
24
+ [16, 18, 20]:SanitizeEmail::TestHelpers#string_matching refers to mail_or_part more than self (FeatureEnvy)
25
+ lib/sanitize_email.rb -- 1 warning:
26
+ [84, 85]:SanitizeEmail#self.sanitary calls SanitizeEmail::Config.config 2 times (DuplicateMethodCall)
27
+ spec/sanitize_email_spec.rb -- 9 warnings:
28
+ [57, 57]:configure_sanitize_email calls options[:force_sanitize] 2 times (DuplicateMethodCall)
29
+ [55, 55]:configure_sanitize_email calls options[:local_environments] 2 times (DuplicateMethodCall)
30
+ [56, 56]:configure_sanitize_email calls options[:sanitized_recipients] 2 times (DuplicateMethodCall)
31
+ [41]:configure_sanitize_email doesn't depend on instance state (UtilityFunction)
32
+ [41]:configure_sanitize_email has approx 15 statements (TooManyStatements)
33
+ [57]:configure_sanitize_email performs a nil-check (NilCheck)
34
+ [68]:funky_config contains iterators nested 2 deep (NestedIterators)
35
+ [62]:funky_config doesn't depend on instance state (UtilityFunction)
36
+ [62]:funky_config has approx 10 statements (TooManyStatements)
37
+ 27 total warnings
data/Rakefile CHANGED
@@ -27,8 +27,36 @@ namespace :test do
27
27
  desc "Test against all supported Rails versions"
28
28
  task :all do
29
29
  %w(3.0.x 3.1.x 3.2.x 4.0.x).each do |version|
30
- sh %[BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet]
31
- sh %[BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec]
30
+ system(<<-EOS
31
+ bash -i -c "rvm use 1.9.3"
32
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
33
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
34
+ EOS
35
+ )
36
+ end
37
+ %w(3.2.x 4.0.x 4.1.x).each do |version|
38
+ system(<<-EOS
39
+ bash -i -c "rvm use 2.0.0"
40
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
41
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
42
+ EOS
43
+ )
44
+ end
45
+ %w(3.2.x 4.0.x 4.1.x).each do |version|
46
+ system(<<-EOS
47
+ bash -i -c "rvm use 2.1.7"
48
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
49
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
50
+ EOS
51
+ )
52
+ end
53
+ %w(3.2.x 4.0.x 4.1.x 4.2.x).each do |version|
54
+ system(<<-EOS
55
+ bash -i -c "rvm use 2.2.3"
56
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle --quiet
57
+ BUNDLE_GEMFILE="gemfiles/Gemfile.rails-#{version}" bundle exec rspec spec
58
+ EOS
59
+ )
32
60
  end
33
61
  end
34
62
  end
@@ -2,4 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem "rails", "~> 3.0"
5
+ gem "rails", "~> 3.0.0"
6
+ gem "reek", "~> 2.0" # for Ruby < 2.0
@@ -2,5 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem "actionmailer", "~> 3.1"
6
- gem "railties", "~> 3.1"
5
+ gem "actionmailer", "~> 3.1.0"
6
+ gem "railties", "~> 3.1.0"
7
+ gem "reek", "~> 2.0" # for Ruby < 2.0
@@ -2,5 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem "actionmailer", "~> 3.2"
6
- gem "railties", "~> 3.2"
5
+ gem "actionmailer", "~> 3.2.0"
6
+ gem "railties", "~> 3.2.0"
@@ -2,5 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec :path => '..'
4
4
 
5
- gem "actionmailer", "~> 4.0"
6
- gem "railties", "~> 4.0"
5
+ gem "actionmailer", "~> 4.0.0"
6
+ gem "railties", "~> 4.0.0"
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem "actionmailer", "~> 4.1.0"
6
+ gem "railties", "~> 4.1.0"
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem "actionmailer", "~> 4.2.0"
6
+ gem "railties", "~> 4.2.0"
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
 
4
4
  module SanitizeEmail
@@ -9,6 +9,7 @@ module SanitizeEmail
9
9
  require 'sanitize_email/overridden_addresses'
10
10
  require 'sanitize_email/bleach'
11
11
 
12
+ # Error is raised when a block parameter is required and not provided to a method
12
13
  class MissingBlockParameter < StandardError; end
13
14
 
14
15
  # Allow non-rails implementations to use this gem
@@ -38,7 +39,7 @@ module SanitizeEmail
38
39
  SanitizeEmail::Config.config[key.to_sym]
39
40
  end
40
41
 
41
- def self.method_missing(name, *args)
42
+ def self.method_missing(name, *_)
42
43
  SanitizeEmail[name]
43
44
  end
44
45
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
 
4
4
  module SanitizeEmail
@@ -7,7 +7,7 @@ module SanitizeEmail
7
7
 
8
8
  # Can override global configs at the instance level.
9
9
  attr_accessor :engage, # Turn sanitization on or off just for this instance
10
- :overridden_addresses
10
+ :overridden_addresses # TODO: Just a stub. Needs actual implementation
11
11
 
12
12
  def initialize(args = {})
13
13
  # Not using extract_options! because non-rails compatibility is a goal
@@ -20,11 +20,11 @@ module SanitizeEmail
20
20
  SanitizeEmail::MailHeaderTools.add_original_addresses_as_headers(message)
21
21
  SanitizeEmail::MailHeaderTools.prepend_custom_subject(message)
22
22
 
23
- o = SanitizeEmail::OverriddenAddresses.new(message)
23
+ overridden = SanitizeEmail::OverriddenAddresses.new(message)
24
24
 
25
- message.to = o.overridden_to
26
- message.cc = o.overridden_cc
27
- message.bcc = o.overridden_bcc
25
+ message.to = overridden.overridden_to
26
+ message.cc = overridden.overridden_cc
27
+ message.bcc = overridden.overridden_bcc
28
28
  end
29
29
  end
30
30
 
@@ -1,7 +1,9 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
 
4
4
  module SanitizeEmail
5
+ # The API for configuring SanitizeEmail is via `SanitizeEmail.config`
6
+ # Available configuration options are listed in the `DEFAULTS`` constant.
5
7
  class Config
6
8
 
7
9
  extend SanitizeEmail::Deprecation
@@ -60,10 +62,13 @@ module SanitizeEmail
60
62
  @config[:sanitized_to] = @config[:sanitized_recipients]
61
63
  end
62
64
  if !@config[:force_sanitize].nil?
63
- replacement = "
64
- Please use SanitizeEmail.force_sanitize or SanitizeEmail.sanitary instead.
65
- Refer to https://github.com/pboling/sanitize_email/wiki for examples."
66
- deprecation("SanitizeEmail::Config.config[:force_sanitize]", replacement)
65
+ deprecation_warning_message(
66
+ <<-EOS
67
+ SanitizeEmail::Config.config[:force_sanitize] is deprecated.
68
+ Please use SanitizeEmail.force_sanitize or SanitizeEmail.sanitary instead.
69
+ Refer to https://github.com/pboling/sanitize_email/wiki for examples.
70
+ EOS
71
+ )
67
72
  SanitizeEmail.force_sanitize = @config[:force_sanitize]
68
73
  end
69
74
  end
@@ -1,9 +1,9 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
- # See http://www.seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
4
- #require 'facets/module/mattr' # gives cattr
5
3
 
6
4
  module SanitizeEmail
5
+ # Provides tools that allow methods to be deprecated with new releases of the gem.
6
+ # See http://www.seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
7
7
  module Deprecation
8
8
 
9
9
  class << self
@@ -38,14 +38,15 @@ module SanitizeEmail
38
38
  end
39
39
 
40
40
  def deprecation(name, replacement = nil)
41
- unless SanitizeEmail::Deprecation.deprecate_in_silence
42
- if replacement
43
- warn "SanitizeEmail: ##{name} deprecated#{replacement}"
44
- else
45
- warn "SanitizeEmail: ##{name} deprecated"
46
- end
41
+ if replacement
42
+ deprecation_warning_message("SanitizeEmail: ##{name} deprecated#{replacement}")
43
+ else
44
+ deprecation_warning_message("SanitizeEmail: ##{name} deprecated")
47
45
  end
48
46
  end
49
47
 
48
+ def deprecation_warning_message(message)
49
+ warn message unless SanitizeEmail::Deprecation.deprecate_in_silence
50
+ end
50
51
  end
51
52
  end
@@ -1,7 +1,8 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
- # For Rails >= 3.1
3
+
4
4
  module SanitizeEmail
5
+ # For Rails >= 3.1
5
6
  class Engine < ::Rails::Engine
6
7
 
7
8
  config.to_prepare do
@@ -1,6 +1,8 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
+
3
4
  module SanitizeEmail
5
+ # Tools for modifying the header of an email
4
6
  module MailHeaderTools
5
7
 
6
8
  def self.prepend_subject_array(message)
@@ -29,9 +31,9 @@ module SanitizeEmail
29
31
  'X-Sanitize-Email-To' => Array(message.to).uniq, # can be an array, so casting it as an array
30
32
  'X-Sanitize-Email-Cc' => Array(message.cc).uniq # can be an array, so casting it as an array
31
33
  # Don't write out the BCC, as those addresses should not be visible in message headers for obvious reasons
32
- }.each { |k, v|
34
+ }.each { |header_key, header_value|
33
35
  # For each type of address line
34
- SanitizeEmail::MailHeaderTools.update_header(k, v, message)
36
+ SanitizeEmail::MailHeaderTools.update_header(header_key, header_value, message)
35
37
  }
36
38
  end
37
39
 
@@ -41,20 +43,15 @@ module SanitizeEmail
41
43
  end
42
44
 
43
45
  # According to https://github.com/mikel/mail this is the correct way to update headers.
44
- def self.update_header(k, v, message)
45
- # For each address, as v can be an array of addresses
46
- Array(v).each_with_index { |a, index|
46
+ def self.update_header(header_key, header_value, message)
47
+ # For each address, as header_value can be an array of addresses
48
+ Array(header_value).each_with_index { |elem, index|
47
49
  num = index + 1
48
- header_key = num > 1 ?
49
- "#{k}-#{index+1}" :
50
- k
51
- #puts "for #{num}: #{header_key}"
52
- message.header[header_key] = a.to_s
53
- # Old way
54
- # Add headers by string concat. Setting hash values on message.headers does nothing, strangely. http://goo.gl/v46GY
55
- #message.header = message.header.to_s.strip + "\n#{k}: #{a}"
56
- } if v
57
- #puts "\nafter message.header:\n #{message.header}\n"
50
+ new_header_key = num > 1 ?
51
+ "#{header_key}-#{num}" :
52
+ header_key
53
+ message.header[new_header_key] = elem.to_s
54
+ } if header_value
58
55
  end
59
56
 
60
57
  end
@@ -1,13 +1,20 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
+
3
4
  module SanitizeEmail
5
+ # Tools for overriding addresses
4
6
  class OverriddenAddresses
5
7
 
6
- class MissingTo < StandardError;
7
- end
8
- class UnknownOverride < StandardError;
9
- end
8
+ # Raised when after applying all sanitization rules there are no addresses to send the email to.
9
+ class MissingTo < StandardError; end
10
+
11
+ # Raised if there is a recipient type that sanitize_email doesn't recognize.
12
+ # If you get this error please report it.
13
+ # recognized recipient types are: TO, CC, and BCC
14
+ class UnknownOverride < StandardError; end
10
15
 
16
+ REPLACE_AT = [/@/, " at "]
17
+ REPLACE_ALLIGATOR = [/[<>]/, "~"]
11
18
  attr_accessor :overridden_to, :overridden_cc, :overridden_bcc,
12
19
  :good_list, # White-listed addresses will not be molested as to, cc, or bcc
13
20
  :bad_list, # Black-listed addresses will be removed from to, cc and bcc when sanitization is engaged
@@ -99,7 +106,7 @@ module SanitizeEmail
99
106
  new_recipient = sanitized_addresses
100
107
  else
101
108
  #puts "SANITIZED: #{sanitized_addresses}"
102
- new_recipient = sanitized_addresses.map { |sanitized| "#{real_recipient.gsub(/@/, ' at ').gsub(/[<>]/, '~')} <#{sanitized}>" }
109
+ new_recipient = sanitized_addresses.map { |sanitized| "#{real_recipient.gsub(REPLACE_AT[0], REPLACE_AT[1]).gsub(/[<>]/, '~')} <#{sanitized}>" }
103
110
  end
104
111
  result << new_recipient
105
112
  result
@@ -1,7 +1,8 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
- # For Rails 3.0, which didn't yet support Engines
3
+
4
4
  module SanitizeEmail
5
+ # For Rails 3.0, which didn't yet support Engines
5
6
  class Railtie < ::Rails::Railtie
6
7
 
7
8
  config.after_initialize do
@@ -1,9 +1,10 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
  require 'sanitize_email/test_helpers'
4
4
  require 'sanitize_email/mail_ext'
5
5
 
6
6
  module SanitizeEmail
7
+ # Provides matchers that can be used in Rspec tests to assert the behavior of email
7
8
  module RspecMatchers
8
9
  include SanitizeEmail::TestHelpers
9
10
  [:from, :to, :cc, :bcc, :reply_to].each do |attribute|
@@ -1,7 +1,11 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
+
3
4
  module SanitizeEmail
5
+ # Helpers for test-unit
4
6
  module TestHelpers
7
+
8
+ # Error raised when unable to match an expected part of email in order to fail the test
5
9
  class UnexpectedMailType < StandardError; end
6
10
 
7
11
  def string_matching_attribute(matcher, part, mail_or_part)
@@ -1,5 +1,6 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
+
3
4
  module SanitizeEmail
4
- VERSION = '1.1.6'
5
+ VERSION = '1.1.7'
5
6
  end
@@ -7,7 +7,10 @@ Gem::Specification.new do |s|
7
7
 
8
8
  s.authors = ["Peter Boling", "John Trupiano", "George Anderson"]
9
9
  s.summary = "Email Condom for your Ruby Server"
10
- s.description = "In Rails, Sinatra, or simply the mail gem: Aids in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses."
10
+ s.description = <<EOS
11
+ Email Condom for your Ruby Server.
12
+ In Rails, Sinatra, et al, or simply the mail gem: Aids in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses.
13
+ EOS
11
14
  s.email = ["peter.boling@gmail.com"]
12
15
  s.extra_rdoc_files = [
13
16
  "CHANGELOG.md",
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
  require 'spec_helper'
4
4
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-13 Peter H. Boling of RailsBling.com
1
+ # Copyright (c) 2008-15 Peter H. Boling of RailsBling.com
2
2
  # Released under the MIT license
3
3
  require 'launchy'
4
4
  require 'mail'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanitize_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-29 00:00:00.000000000 Z
13
+ date: 2015-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -180,9 +180,9 @@ dependencies:
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
- description: 'In Rails, Sinatra, or simply the mail gem: Aids in development, testing,
184
- qa, and production troubleshooting of email issues without worrying that emails
185
- will get sent to actual live addresses.'
183
+ description: |2
184
+ Email Condom for your Ruby Server.
185
+ In Rails, Sinatra, et al, or simply the mail gem: Aids in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses.
186
186
  email: peter.boling@gmail.com
187
187
  executables: []
188
188
  extensions: []
@@ -193,6 +193,7 @@ extra_rdoc_files:
193
193
  files:
194
194
  - ".coveralls.yml"
195
195
  - ".gitignore"
196
+ - ".reek"
196
197
  - ".rspec"
197
198
  - ".ruby-gemset"
198
199
  - ".ruby-version"
@@ -207,6 +208,8 @@ files:
207
208
  - gemfiles/Gemfile.rails-3.1.x
208
209
  - gemfiles/Gemfile.rails-3.2.x
209
210
  - gemfiles/Gemfile.rails-4.0.x
211
+ - gemfiles/Gemfile.rails-4.1.x
212
+ - gemfiles/Gemfile.rails-4.2.x
210
213
  - init.rb
211
214
  - lib/sanitize_email.rb
212
215
  - lib/sanitize_email/bleach.rb