sanitize_email 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -5,4 +5,3 @@ rvm:
5
5
  - jruby-19mode
6
6
  - rbx-19mode
7
7
  - ruby-head
8
- - jruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ Version 1.0.5 - DEC.20.2012
2
+
3
+ * Fixes Compatibility with Rails 3.0 by David Morton
4
+ * Added header tests to ensure original header markers do not appear when sanitize is disabled by Harry Lascelles
5
+ * Added tests and email_spec for have_header matcher by Harry Lascelles
6
+ * Make activation_proc option a bit more configurable by Nikita Fedyashev
7
+ * Adding message to engage proc, so we can sanitize on a message by message basis by Harry Lascelles
8
+ * Allowing for nil ccs and bccs by Harry Lascelles
9
+ * Adding original emails as headers, except for bcc by Harry Lascelles
10
+
11
+ Version 1.0.4 - SEP.10.2012
12
+
13
+ * Removes facets dependency, upgrades to rspec v2.11 by Peter Boling
14
+ * REEK refactoring by Peter Boling
15
+ * Improve handling of mal-formed calls to (un)sanitary (raises error) by Peter Boling
16
+ * code cleanup by Peter Boling
17
+ * Put some examples back in the README, until I improve and link to the wiki. :/
18
+
19
+ Version 1.0.3 - AUG.12.2012
20
+
21
+ * Accidentally broke spec suite with 1.0.2 - fixed
22
+ * Expanded spec suite
23
+ * Split test_helpers from rspec_matchers (test_helpers may be useful in TestUnit
24
+ * Moving Examples from README to wiki
25
+ * Document and implement working deprecation of version 0's SanitizeEmail::Config.config[:force_sanitize] behavior
26
+ * Now use SanitizeEmail.force_sanitize = true # or false or nil
27
+
28
+ Version 1.0.2 - AUG.11.2012
29
+
30
+ * Massive improvement to spec suite, and found bleeding
31
+ * needed to unregister the interceptors:
32
+ * Mail.class_variable_get(:@@delivery_interceptors).pop
33
+ * Added SanitizeEmail.deprecate_in_silence
34
+ * Added SanitizeEmail.sanitary &block
35
+ * Local overrides to SanitizeEmail config for specific local purpose
36
+ * Force Sanitization On for a block
37
+ * Added SanitizeEmail.unsanitary &block
38
+ * Force Sanitization Off for a block
39
+ * Added SanitizeEmail.force_sanitize = true # or false or nil
40
+ * Force Sanitization On or Off
41
+
42
+ Version 1.0.1 - Unintentional, unexpected bump behavior from gem-release gem (Issues #24 & #25)
43
+
44
+ Version 1.0.0.rc3 - AUG.08.2012
45
+
46
+ * Forgot to switch from jeweler to gem-release, so making appropriate changes and bumping again
47
+ * Aligning closer to bundler gem defaults
48
+ * Removing Rails dependency - Should work with Sinatra, or any Mail-like interface
49
+ * Added facets dependency to get cattr functionality (and hopefully other cool stuff)
50
+ * Gem dependencies in gemspec
51
+
52
+ Version 1.0.0.rc2 - AUG.08.2012 - botched
53
+
54
+ * Bug: loading the gem in a rails app broke mailer specs in the app - Fixed
55
+ * https://github.com/pboling/sanitize_email/issues/4
56
+ * Moved MIT-LICENSE to LICENSE, updated years
57
+ * Added Travis-CI for... CI.
58
+
59
+ Version 1.0.0.rc1
60
+
61
+ * Added a good_list and a bad_list (whitelist and blacklist)
62
+ * Added Deprecation library
63
+ * Refactored Sanitization module into Hook class
64
+ * Renamed Hook Class to Bleach Class
65
+ * Improve support for non-rails implementations
66
+ * Deprecated local_environments in favor of local_environment_proc
67
+ * Deprecated sanitized_recipients in favor of sanitized_to
68
+ * More specs
69
+
70
+ Version 1.0.0.alpha2
71
+
72
+ * Complete refactor! Implementing initial support for Rails >= 3.0 (new ActionMailer API)
73
+ * Support for Rails <= 2.X remains in version 0.X.X releases.
74
+ * NinthBit namespace is now SanitizeEmail namespace
75
+ * Now has a first class Config class
76
+
77
+ XXXXXXXXXXXXXXXXXXXXXXX Rail 3.0+ Only Form here on up! XXXXXXXXXXXXXXXXXXXXXXX
78
+
79
+ Version 0.3.8
80
+
81
+ * Update specs, note requirement of Rails 2.3 or below to run spec quite.
82
+ * Support use_actual_email_prepended_to_subject
83
+ * Fix environment check for old versions of Rails
84
+ * Improved Readme
85
+
86
+ Version 0.3.7
87
+
88
+ * Improved Installation instructions
89
+ * Fixed so tests run from inside a rails app (previously only ran standalone)
90
+
91
+ Version 0.3.6
92
+
93
+ * Fixed Installation instructions
94
+ * Improved README
95
+
96
+ Old version?
97
+
98
+ * Fixed require paths
99
+ * added about.yml and this CHANGELOG
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanitize_email (1.0.3)
4
+ sanitize_email (1.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -37,6 +37,9 @@ GEM
37
37
  arel (3.0.2)
38
38
  builder (3.0.0)
39
39
  diff-lcs (1.1.3)
40
+ email_spec (1.2.1)
41
+ mail (~> 2.2)
42
+ rspec (~> 2.0)
40
43
  erubis (2.7.0)
41
44
  hike (1.2.1)
42
45
  i18n (0.6.0)
@@ -117,6 +120,7 @@ PLATFORMS
117
120
 
118
121
  DEPENDENCIES
119
122
  actionmailer (> 3)
123
+ email_spec
120
124
  launchy
121
125
  letter_opener
122
126
  mail
@@ -1,43 +1,63 @@
1
- = sanitize_email {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/pboling/sanitize_email] {<img src="https://secure.travis-ci.org/pboling/sanitize_email.png?branch=master" alt="Build Status" />}[http://travis-ci.org/pboling/sanitize_email]
1
+ # sanitize_email
2
2
 
3
- This gem allows you to globally override your mail delivery settings. It's particularly helpful when you want to omit the delivery of email (e.g. in development/test environments) or alter the to/cc/bcc (e.g. in staging or demo environments) of all email generated from your application.
3
+ This gem allows you to override your mail delivery settings, globally or in a local context. It's particularly helpful when you want to omit the delivery of email (e.g. in development/test environments) or alter the to/cc/bcc (e.g. in staging or demo environments) of all email generated from your application.
4
4
 
5
- It is a "configure it and forget it" type gem that requires very little setup. It uses the 'register_interceptor' API of ActionMailer or the Mail gem. It should work with Rails >3 or any Ruby app that is using Mail or ActionMailer gems.
5
+ * compatible with Rails >= 3.X (Note: 3.0 requires version >= 1.0.5)
6
+ * compatible with any Ruby app with a Mail handler that uses the `register_interceptor` API (a la ActionMailer and Mail gems)
7
+ * configure it and forget it
8
+ * little configuration required
9
+ * solves common problems in ruby web applications that use email
10
+ * provides test helpers and spec matchers to assist with testing email content delivery
6
11
 
7
- It currently solves five (3!) common problems in ruby web applications that use email:
12
+ ## Summary
8
13
 
9
- === #1 Working Locally with Production Data
14
+ | Project | Sanitize Email |
15
+ |---------------- | ----------------- |
16
+ | gem name | sanitize_email |
17
+ | license | MIT |
18
+ | homepage | https://github.com/pboling/sanitize_email |
19
+ | documentation | http://rdoc.info/github/pboling/sanitize_email/frames |
20
+ | author | [Peter Boling](railsbling.com) [![Endorse Me](http://api.coderwall.com/pboling/endorsecount.png)](http://api.coderwall.com/pboling/endorsecount.png) |
21
+ | CI | https://travis-ci.org/pboling/sanitize_email [![Build Status](https://secure.travis-ci.org/pboling/sanitize_email.png?branch=master)](https://travis-ci.org/pboling/sanitize_email) |
22
+ | QA | https://codeclimate.com/github/pboling/sanitize_email [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/pboling/sanitize_email) |
10
23
 
11
- * I have a production site with live data.
12
- * I dump the live data and securely transfer it to another machine (rync -e ssh), and import it using a {few rake tasks}[http://github.com/pboling/sir-du-bob]
13
- * On this separate machine (staging, or development) I run tests, and test various features which often send out email (registration/signup, order placement, etc.)
14
- * I usually want the emails to get sent from these non-production environments so I can verify what they look like when sent, but I don't ever want to risk them getting sent to addresses that are not mine.
15
24
 
16
- === #2 Re-routing Email on a Staging or QA Server
25
+ ## Working Locally with Production Data
26
+
27
+ 1. Have a production site with live data
28
+ 2. Dump the live data and securely transfer it to another machine (e.g. rync -e ssh)
29
+ 3. Import it into a development database
30
+ 4. Test features which send out email (registration/signup, order placement, etc.)
31
+ 5. Emails get sent (in real-life!) but to sanitized email recipients
32
+ 6. Verify what they look like when sent
33
+ 7. Iterate on email content design
34
+ 8. No risk of emailing production addresses
35
+
36
+ ## Re-routing Email on a Staging or QA Server
17
37
 
18
38
  Another very important use case for me is to transparently re-route email generated from a staging or QA server to an appropriate person. For example, it's common for us to set up a staging server for a client to use to view our progress and test out new features. It's important for any email that is generated from our web application be delivered to the client's inbox so that they can review the content and ensure that it's acceptable. Similarly, we set up QA instances for our own QA team and we use {rails-caddy}[http://github.com/jtrupiano/rails-caddy] to allow each QA person to configure it specifically for them.
19
39
 
20
- === #3 Testing Email from a Hot Production Server
40
+ ## Testing Email from a Hot Production Server
21
41
 
22
42
  If you install this gem on a production server (which I don't always do), you can load up script/console and override the to/cc/bcc on all emails for the duration of your console session. This allows you to poke and prod a live production instance, and route all email to your own inbox for inspection. The best part is that this can all be accomplished without changing a single line of your application code.
23
43
 
24
- == Install Like a Boss
44
+ ## Install Like a Boss
25
45
 
26
46
  [sudo] gem install sanitize_email
27
47
 
28
- == Setup With An Axe
48
+ ## Setup With An Axe
29
49
 
30
50
  Customize and add to an initializer:
31
51
 
32
- SanitizeEmail::Config.configure do |config|
33
- config[:sanitized_to] = 'to@sanitize_email.org'
34
- config[:sanitized_cc] = 'cc@sanitize_email.org'
35
- config[:sanitized_bcc] = 'bcc@sanitize_email.org'
36
- # sanitize emails from development and test, or set whatever logic should turn sanitize_email on and off here:
37
- config[:activation_proc] = Proc.new { %w(development test).include?(Rails.env) }
38
- config[:use_actual_email_prepended_to_subject] = true # or false
39
- config[:use_actual_email_as_sanitized_user_name] = true # or false
40
- end
52
+ SanitizeEmail::Config.configure do |config|
53
+ config[:sanitized_to] = 'to@sanitize_email.org'
54
+ config[:sanitized_cc] = 'cc@sanitize_email.org'
55
+ config[:sanitized_bcc] = 'bcc@sanitize_email.org'
56
+ # sanitize emails from development and test, or set whatever logic should turn sanitize_email on and off here:
57
+ config[:activation_proc] = Proc.new { %w(development test).include?(Rails.env) }
58
+ config[:use_actual_email_prepended_to_subject] = true # or false
59
+ config[:use_actual_email_as_sanitized_user_name] = true # or false
60
+ end
41
61
 
42
62
  Keep in mind, this is ruby (and possibly rails), so you can add conditionals or utilize different environment.rb files to customize these settings on a per-environment basis.
43
63
 
@@ -88,7 +108,7 @@ John Trupiano did the initial gemification and some refactoring.
88
108
 
89
109
  == Contributors
90
110
 
91
- George Anderson's work / improvements have been pulled in, along with several other contributors, which can be seen in the Network view on github. Thanks!
111
+ See the [Network View](https://github.com/pboling/sanitize_email/network) and the [CHANGELOG](https://github.com/pboling/sanitize_email/blob/master/CHANGELOG.md)
92
112
 
93
113
  == References
94
114
 
@@ -99,6 +119,6 @@ George Anderson's work / improvements have been pulled in, along with several ot
99
119
 
100
120
  == Legal Stuff
101
121
 
102
- * Copyright (c) 2008-2012 {Peter H. Boling}[http://www.peterboling.com/about.html] of {9thBit LLC}[http://www.peterboling.com/]
122
+ * Copyright (c) 2008-2012 {Peter H. Boling}[http://www.railsbling.com] of {9thBit LLC}[http://www.peterboling.com/]
103
123
  * Copyright (c) 2009 {John Trupiano}[http://smartlogicsolutions.com/wiki/John_Trupiano] of {SmartLogic Solutions, LLC}[http://www.smartlogicsolutions.com]
104
124
  * Released under the MIT license
data/Rakefile CHANGED
@@ -25,10 +25,10 @@ end
25
25
  task :default => :spec
26
26
 
27
27
  require 'rdoc/task'
28
+ require File.expand_path('../lib/sanitize_email/version', __FILE__)
28
29
  Rake::RDocTask.new do |rdoc|
29
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
30
  rdoc.rdoc_dir = 'rdoc'
31
- rdoc.title = "SanitizeEmail #{version}"
31
+ rdoc.title = "SanitizeEmail #{SanitizeEmail::VERSION}"
32
32
  rdoc.options << '--line-numbers'
33
33
  rdoc.rdoc_files.include('README*')
34
34
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -4,39 +4,63 @@
4
4
  module SanitizeEmail
5
5
  class Bleach
6
6
 
7
- class MissingTo < StandardError; end
8
- class UnknownOverride < StandardError; end
7
+ class MissingTo < StandardError;
8
+ end
9
+ class UnknownOverride < StandardError;
10
+ end
9
11
 
10
12
  # Can override global configs at the instance level.
11
13
  attr_accessor :engage, # Turn sanitization on or off just for this instance
12
- :sanitized_to, :sanitized_cc, :sanitized_bcc, # Replace non-white-listed addresses with these sanitized addresses.
13
- :good_list, # White-listed addresses will not be molested as to, cc, or bcc
14
- :bad_list, # Black-listed addresses will be removed from to, cc and bcc when sanitization is engaged
15
- :injected # Track whether or not the subject has been injected with usernames
14
+ :sanitized_to, :sanitized_cc, :sanitized_bcc, # Replace non-white-listed addresses with these sanitized addresses.
15
+ :good_list, # White-listed addresses will not be molested as to, cc, or bcc
16
+ :bad_list, # Black-listed addresses will be removed from to, cc and bcc when sanitization is engaged
17
+ :injected # Track whether or not the subject has been injected with usernames
16
18
 
17
19
  def initialize(args = {})
18
20
  # Not using extract_options! because non-rails compatibility is a goal
19
- @sanitized_to = args[:sanitized_to] || SanitizeEmail[:sanitized_to]
20
- @sanitized_cc = args[:sanitized_cc] || SanitizeEmail[:sanitized_cc]
21
- @sanitized_bcc = args[:sanitized_bcc] || SanitizeEmail[:sanitized_bcc]
22
- @good_list = args[:good_list] || SanitizeEmail[:good_list] || []
23
- @bad_list = args[:bad_list] || SanitizeEmail[:bad_list] || []
24
- @engage = args[:engage] || SanitizeEmail[:engage]
21
+ @sanitized_to = args[:sanitized_to] || SanitizeEmail[:sanitized_to]
22
+ @sanitized_cc = args[:sanitized_cc] || SanitizeEmail[:sanitized_cc]
23
+ @sanitized_bcc = args[:sanitized_bcc] || SanitizeEmail[:sanitized_bcc]
24
+ @good_list = args[:good_list] || SanitizeEmail[:good_list] || []
25
+ @bad_list = args[:bad_list] || SanitizeEmail[:bad_list] || []
26
+ @engage = args[:engage] || SanitizeEmail[:engage]
25
27
  @injected = false
26
28
  end
27
29
 
28
30
  # If all recipient addresses are white-listed the field is left alone.
29
31
  def delivering_email(message)
30
- if self.sanitize_engaged?
32
+ if self.sanitize_engaged?(message)
33
+ # Cache the correct addresses. These will get overwritten when the
34
+ cache_to = self.to_override(message.to)
35
+ cache_cc = self.cc_override(message.cc)
36
+ cache_bcc = self.bcc_override(message.bcc)
37
+
38
+ add_original_addresses_as_headers(message)
39
+
31
40
  message.subject = self.subject_override(message.subject, message.to) if SanitizeEmail.use_actual_email_prepended_to_subject
32
- message.to = self.to_override(message.to)
33
- message.cc = self.cc_override(message.cc)
34
- message.bcc = self.bcc_override(message.bcc)
41
+ message.to = cache_to
42
+ message.cc = cache_cc
43
+ message.bcc = cache_bcc
35
44
  end
36
45
  end
37
46
 
38
- def activate?
39
- SanitizeEmail.activation_proc.call if SanitizeEmail.activation_proc.respond_to?(:call)
47
+ def add_original_addresses_as_headers(message)
48
+ ## Add headers by string concat. Setting hash values on message.headers does nothing, strangely. http://goo.gl/v46GY
49
+ {
50
+ 'X-Sanitize-Email-To' => message.to,
51
+ 'X-Sanitize-Email-Cc' => message.cc
52
+ # Don't write out the BCC, as those addresses should not be visible in message headers for obvious reasons
53
+ }.each { |k, v|
54
+ # For each type of address line
55
+ v.each { |a|
56
+ # For each address
57
+ message.header = message.header.to_s + "\n#{k}: #{a}"
58
+ } if v
59
+ }
60
+ end
61
+
62
+ def activate?(message)
63
+ SanitizeEmail.activation_proc.call(message) if SanitizeEmail.activation_proc.respond_to?(:call)
40
64
  end
41
65
 
42
66
  # This method will be called by the Hook to determine if an override should occur
@@ -49,7 +73,7 @@ module SanitizeEmail
49
73
  # Note: Number 1 is the method used by the SanitizeEmail.sanitary block
50
74
  # Note: Number 2 would not be used unless you setup your own register_interceptor)
51
75
  # If installed but not configured, sanitize email DOES NOTHING. Until configured the defaults leave it turned off.
52
- def sanitize_engaged?
76
+ def sanitize_engaged?(message)
53
77
 
54
78
  # Has it been forced via the force_sanitize mattr?
55
79
  forced = SanitizeEmail.force_sanitize
@@ -60,7 +84,7 @@ module SanitizeEmail
60
84
  return engaged unless engaged.nil?
61
85
 
62
86
  # Should we sanitize due to the activation_proc?
63
- return self.activate?
87
+ return self.activate?(message)
64
88
 
65
89
  end
66
90
 
@@ -68,7 +92,7 @@ module SanitizeEmail
68
92
  if !actual_addresses.respond_to?(:join)
69
93
  real_subject
70
94
  else
71
- "(#{actual_addresses.join(',').gsub(/@/,' at ').gsub(/[<>]/,'~')}) #{real_subject}"
95
+ "(#{actual_addresses.join(',').gsub(/@/, ' at ').gsub(/[<>]/, '~')}) #{real_subject}"
72
96
  end
73
97
  end
74
98
 
@@ -94,8 +118,10 @@ module SanitizeEmail
94
118
  # TODO: How does this handle email addresses with user names like "Foo Example <foo@example.org>"
95
119
  has_address = self.send(list_type).include?(address)
96
120
  case list_type
97
- when :good_list then has_address ? address : nil
98
- when :bad_list then has_address ? nil : address
121
+ when :good_list then
122
+ has_address ? address : nil
123
+ when :bad_list then
124
+ has_address ? nil : address
99
125
  end
100
126
  end
101
127
 
@@ -104,7 +130,7 @@ module SanitizeEmail
104
130
  if real_recipient.nil?
105
131
  new_recipient = sanitized_addresses
106
132
  else
107
- new_recipient = sanitized_addresses.map{|sanitized| "#{real_recipient.gsub(/@/,' at ').gsub(/[<>]/,'~')} <#{sanitized}>"}
133
+ new_recipient = sanitized_addresses.map { |sanitized| "#{real_recipient.gsub(/@/, ' at ').gsub(/[<>]/, '~')} <#{sanitized}>" }
108
134
  end
109
135
  result << new_recipient
110
136
  result
@@ -121,10 +147,14 @@ module SanitizeEmail
121
147
 
122
148
  def sanitize_addresses(type)
123
149
  case type
124
- when :to then Array(self.sanitized_to)
125
- when :cc then Array(self.sanitized_cc)
126
- when :bcc then Array(self.sanitized_bcc)
127
- else raise UnknownOverride, "unknown email override"
150
+ when :to then
151
+ Array(self.sanitized_to)
152
+ when :cc then
153
+ Array(self.sanitized_cc)
154
+ when :bcc then
155
+ Array(self.sanitized_bcc)
156
+ else
157
+ raise UnknownOverride, "unknown email override"
128
158
  end
129
159
  end
130
160
 
@@ -137,35 +167,36 @@ module SanitizeEmail
137
167
 
138
168
  def override_email(type, actual_addresses)
139
169
  # Normalized to an arrays
140
- #puts "override_email 1: #{type} - #{actual_addresses}"
170
+ #puts "override_email 1: #{type} - #{actual_addresses}"
141
171
  real_addresses = Array(actual_addresses)
142
172
 
143
173
  #puts "override_email 2: #{type} - #{real_addresses}"
144
- # If there were no original recipients, then we DO NOT override the nil with the sanitized recipients
174
+ # If there were no original recipients, then we DO NOT override the nil with the sanitized recipients
145
175
  return [] if real_addresses.empty?
146
176
 
147
177
  good_listed = good_listize(real_addresses)
148
178
  #puts "override_email 3: #{type} - #{good_listed}"
149
- # If there are good_list addresses to send to then use them as is, no mods needed
179
+ # If there are good_list addresses to send to then use them as is, no mods needed
150
180
  return good_listed unless good_listed.empty?
151
181
 
182
+ # TODO: Allow overriding if an addressed email is on the good list?
152
183
  # If there are no sanitized addresses we can't override!
153
184
  sanitized_addresses = sanitize_addresses(type)
154
- #puts "override_email 3: #{type} - #{sanitized_addresses}"
185
+ #puts "override_email 3: #{type} - #{sanitized_addresses}"
155
186
  return [] if sanitized_addresses.empty?
156
187
 
157
188
  # At this point it is assured that the address list will need to be sanitized
158
189
  # One more check to ensure none of the configured sanitized email addresses are on the bad_list
159
190
  sanitized_addresses = self.clean_addresses(sanitized_addresses, :bad_list)
160
- #puts "override_email 4: #{type} - #{sanitized_addresses}"
191
+ #puts "override_email 4: #{type} - #{sanitized_addresses}"
161
192
 
162
193
  # If we don't want to inject the 'email' in the 'user name' section of the sanitized recipients,
163
194
  # then just return the default sanitized recipients
164
195
  return sanitized_addresses unless SanitizeEmail.use_actual_email_as_sanitized_user_name
165
196
 
166
197
  with_user_names = self.inject_user_names(real_addresses, sanitized_addresses)
167
- #puts "real_addresses 2: #{real_addresses}"
168
- #puts "override_email 5: #{type} - #{with_user_names}"
198
+ #puts "real_addresses 2: #{real_addresses}"
199
+ #puts "override_email 5: #{type} - #{with_user_names}"
169
200
  # Otherwise inject the email as the 'user name'
170
201
  return with_user_names
171
202
  end
@@ -4,7 +4,7 @@
4
4
  module SanitizeEmail
5
5
  class Railtie < ::Rails::Railtie
6
6
 
7
- config.before_configuration do
7
+ config.after_initialize do
8
8
  ActionMailer::Base.register_interceptor(SanitizeEmail::Bleach.new)
9
9
  end
10
10
 
@@ -1,5 +1,5 @@
1
1
  #Copyright (c) 2008-12 Peter H. Boling of 9thBit LLC
2
2
  #Released under the MIT license
3
3
  module SanitizeEmail
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
@@ -7,14 +7,13 @@ Gem::Specification.new do |s|
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Peter Boling", "John Trupiano", "George Anderson"]
10
- s.date = "2012-08-12"
11
10
  s.summary = "Rails/Sinatra/Mail gem: Test email abilities without ever sending a message to actual live addresses"
12
11
  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."
13
12
  s.email = ["peter.boling@gmail.com", "jtrupiano@gmail.com", "george@benevolentcode.com"]
14
13
  s.extra_rdoc_files = [
15
- "CHANGELOG",
14
+ "CHANGELOG.md",
16
15
  "LICENSE",
17
- "README.rdoc"
16
+ "README.md"
18
17
  ]
19
18
  s.files = `git ls-files`.split($\)
20
19
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -39,5 +38,6 @@ Gem::Specification.new do |s|
39
38
  s.add_development_dependency(%q<reek>, [">= 1.2.8"])
40
39
  s.add_development_dependency(%q<roodi>, [">= 2.1.0"])
41
40
  s.add_development_dependency(%q<rake>, [">= 0"])
41
+ s.add_development_dependency(%q<email_spec>, [">= 0"])
42
42
  end
43
43
 
@@ -122,6 +122,9 @@ describe SanitizeEmail do
122
122
  @email_message.should have_to("to@sanitize_email.org")
123
123
  @email_message.should have_cc("cc@sanitize_email.org")
124
124
  @email_message.should have_bcc("bcc@sanitize_email.org")
125
+ @email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
126
+ @email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
127
+ @email_message.should_not have_header("X-Sanitize-Email-Bcc")
125
128
  end
126
129
  it "should not prepend originals by default" do
127
130
  @email_message.should_not have_to_username("to at example.org <to@sanitize_email.org>")
@@ -145,6 +148,9 @@ describe SanitizeEmail do
145
148
  @email_message.should have_to("to@sanitize_email.org")
146
149
  @email_message.should have_cc("cc@sanitize_email.org")
147
150
  @email_message.should have_bcc("bcc@sanitize_email.org")
151
+ @email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
152
+ @email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
153
+ @email_message.should_not have_header("X-Sanitize-Email-Bcc")
148
154
  end
149
155
  end
150
156
  context "false" do
@@ -162,6 +168,9 @@ describe SanitizeEmail do
162
168
  @email_message.should have_to("to@example.org")
163
169
  @email_message.should have_cc("cc@example.org")
164
170
  @email_message.should have_bcc("bcc@example.org")
171
+ @email_message.should_not have_header("X-Sanitize-Email-To")
172
+ @email_message.should_not have_header("X-Sanitize-Email-Cc")
173
+ @email_message.should_not have_header("X-Sanitize-Email-Bcc")
165
174
  end
166
175
  end
167
176
  context "nil" do
@@ -181,6 +190,9 @@ describe SanitizeEmail do
181
190
  @email_message.should have_to("to@sanitize_email.org")
182
191
  @email_message.should have_cc("cc@sanitize_email.org")
183
192
  @email_message.should have_bcc("bcc@sanitize_email.org")
193
+ @email_message.should have_header("X-Sanitize-Email-To", "to@example.org")
194
+ @email_message.should have_header("X-Sanitize-Email-Cc", "cc@example.org")
195
+ @email_message.should_not have_header("X-Sanitize-Email-Bcc")
184
196
  end
185
197
  end
186
198
  context "activation proc disables" do
@@ -199,6 +211,9 @@ describe SanitizeEmail do
199
211
  @email_message.should have_to("to@example.org")
200
212
  @email_message.should have_cc("cc@example.org")
201
213
  @email_message.should have_bcc("bcc@example.org")
214
+ @email_message.should_not have_header("X-Sanitize-Email-To")
215
+ @email_message.should_not have_header("X-Sanitize-Email-Cc")
216
+ @email_message.should_not have_header("X-Sanitize-Email-Bcc")
202
217
  end
203
218
  end
204
219
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,8 @@ require 'launchy'
4
4
  require 'mail'
5
5
  require 'rails'
6
6
  require 'letter_opener'
7
+ require 'action_mailer'
8
+ require 'email_spec'
7
9
 
8
10
  # Requires supporting files with custom matchers and macros, etc,
9
11
  # in ./support/ and its subdirectories.
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.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-12 00:00:00.000000000 Z
14
+ date: 2012-12-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -173,6 +173,22 @@ dependencies:
173
173
  - - ! '>='
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
+ - !ruby/object:Gem::Dependency
177
+ name: email_spec
178
+ requirement: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
176
192
  description: ! 'In Rails, Sinatra, or simply the mail gem: Aids in development, testing,
177
193
  qa, and production troubleshooting of email issues without worrying that emails
178
194
  will get sent to actual live addresses.'
@@ -183,18 +199,18 @@ email:
183
199
  executables: []
184
200
  extensions: []
185
201
  extra_rdoc_files:
186
- - CHANGELOG
202
+ - CHANGELOG.md
187
203
  - LICENSE
188
- - README.rdoc
204
+ - README.md
189
205
  files:
190
206
  - .gitignore
191
207
  - .rspec
192
208
  - .travis.yml
193
- - CHANGELOG
209
+ - CHANGELOG.md
194
210
  - Gemfile
195
211
  - Gemfile.lock
196
212
  - LICENSE
197
- - README.rdoc
213
+ - README.md
198
214
  - REEK
199
215
  - Rakefile
200
216
  - init.rb
@@ -239,4 +255,3 @@ summary: ! 'Rails/Sinatra/Mail gem: Test email abilities without ever sending a
239
255
  test_files:
240
256
  - spec/sanitize_email_spec.rb
241
257
  - spec/spec_helper.rb
242
- has_rdoc:
data/CHANGELOG DELETED
@@ -1,78 +0,0 @@
1
- Version 1.0.4 - SEP.10.2012
2
- * Removes facets dependency, upgrades to rspec v2.11 by Peter Boling
3
- * REEK refactoring by Peter Boling
4
- * Improve handling of mal-formed calls to (un)sanitary (raises error) by Peter Boling
5
- * code cleanup by Peter Boling
6
- * Put some examples back in the README, until I improve and link to the wiki. :/
7
-
8
- Version 1.0.3 - AUG.12.2012
9
- - Accidentally broke spec suite with 1.0.2 - fixed
10
- - Expanded spec suite
11
- - Split test_helpers from rspec_matchers (test_helpers may be useful in TestUnit
12
- - Moving Examples from README to wiki
13
- - Document and implement working deprecation of version 0's SanitizeEmail::Config.config[:force_sanitize] behavior
14
- - Now use SanitizeEmail.force_sanitize = true # or false or nil
15
-
16
- Version 1.0.2 - AUG.11.2012
17
- - Massive improvement to spec suite, and found bleeding
18
- - needed to unregister the interceptors:
19
- - Mail.class_variable_get(:@@delivery_interceptors).pop
20
- - Added SanitizeEmail.deprecate_in_silence
21
- - Added SanitizeEmail.sanitary &block
22
- - Local overrides to SanitizeEmail config for specific local purpose
23
- - Force Sanitization On for a block
24
- - Added SanitizeEmail.unsanitary &block
25
- - Force Sanitization Off for a block
26
- - Added SanitizeEmail.force_sanitize = true # or false or nil
27
- - Force Sanitization On or Off
28
-
29
- Version 1.0.1 - Unintentional, unexpected bump behavior from gem-release gem (Issues #24 & #25)
30
-
31
- Version 1.0.0.rc3 - AUG.08.2012
32
- - Forgot to switch from jeweler to gem-release, so making appropriate changes and bumping again
33
- - Aligning closer to bundler gem defaults
34
- - Removing Rails dependency - Should work with Sinatra, or any Mail-like interface
35
- - Added facets dependency to get cattr functionality (and hopefully other cool stuff)
36
- - Gem dependencies in gemspec
37
-
38
- Version 1.0.0.rc2 - AUG.08.2012 - botched
39
- - Bug: loading the gem in a rails app broke mailer specs in the app - Fixed
40
- - https://github.com/pboling/sanitize_email/issues/4
41
- - Moved MIT-LICENSE to LICENSE, updated years
42
- - Added Travis-CI for... CI.
43
-
44
- Version 1.0.0.rc1
45
- - Added a good_list and a bad_list (whitelist and blacklist)
46
- - Added Deprecation library
47
- - Refactored Sanitization module into Hook class
48
- - Renamed Hook Class to Bleach Class
49
- - Improve support for non-rails implementations
50
- - Deprecated local_environments in favor of local_environment_proc
51
- - Deprecated sanitized_recipients in favor of sanitized_to
52
- - More specs
53
-
54
- Version 1.0.0.alpha2
55
- - Complete refactor! Implementing initial support for Rails >= 3.0 (new ActionMailer API)
56
- - Support for Rails <= 2.X remains in version 0.X.X releases.
57
- - NinthBit namespace is now SanitizeEmail namespace
58
- - Now has a first class Config class
59
-
60
- XXXXXXXXXXXXXXXXXXXXXXX Rail 3.0+ Only Form here on up! XXXXXXXXXXXXXXXXXXXXXXX
61
-
62
- Version 0.3.8
63
- - Update specs, note requirement of Rails 2.3 or below to run spec quite.
64
- - Support use_actual_email_prepended_to_subject
65
- - Fix environment check for old versions of Rails
66
- - Improved Readme
67
-
68
- Version 0.3.7
69
- - Improved Installation instructions
70
- - Fixed so tests run from inside a rails app (previously only ran standalone)
71
-
72
- Version 0.3.6
73
- - Fixed Installation instructions
74
- - Improved README
75
-
76
- Old version?
77
- - Fixed require paths
78
- - added about.yml and this CHANGELOG