Hello community,

here is the log from the commit of package rubygem-exception_notification for 
openSUSE:Factory checked in at 2016-01-28 17:22:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-exception_notification (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-exception_notification.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-exception_notification"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/rubygem-exception_notification/rubygem-exception_notification.changes
    2016-01-12 16:12:08.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-exception_notification.new/rubygem-exception_notification.changes
       2016-01-28 17:22:57.000000000 +0100
@@ -1,0 +2,20 @@
+Thu Jan 21 05:34:37 UTC 2016 - co...@suse.com
+
+- updated to version 4.1.4
+ see installed CHANGELOG.rdoc
+
+-------------------------------------------------------------------
+Wed Dec 23 05:33:29 UTC 2015 - co...@suse.com
+
+- updated to version 4.1.3
+ see installed CHANGELOG.rdoc
+
+  == undefined
+  
+  * enhancements
+    * Add a way to have a backtrace callback on notifiers (by @pcboy)
+  
+  * bug fixes
+    * Fix incompatible character encodings error (by @san650)
+
+-------------------------------------------------------------------

Old:
----
  exception_notification-4.1.2.gem

New:
----
  exception_notification-4.1.4.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-exception_notification.spec ++++++
--- /var/tmp/diff_new_pack.mgbyWJ/_old  2016-01-28 17:22:58.000000000 +0100
+++ /var/tmp/diff_new_pack.mgbyWJ/_new  2016-01-28 17:22:58.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-exception_notification
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-exception_notification
-Version:        4.1.2
+Version:        4.1.4
 Release:        0
 %define mod_name exception_notification
 %define mod_full_name %{mod_name}-%{version}

++++++ exception_notification-4.1.2.gem -> exception_notification-4.1.4.gem 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.rdoc new/CHANGELOG.rdoc
--- old/CHANGELOG.rdoc  2015-12-04 21:45:42.000000000 +0100
+++ new/CHANGELOG.rdoc  2016-01-07 22:21:05.000000000 +0100
@@ -1,3 +1,17 @@
+== 4.1.4
+
+* bug fixes
+  * HTML-escape exception messages sent to hipchat
+  * Send the correct options in send_notice
+
+== 4.1.3
+
+* enhancements
+  * Add a way to have a backtrace callback on notifiers (by @pcboy)
+
+* bug fixes
+  * Fix incompatible character encodings error (by @san650)
+
 == 4.1.2
 * enhancements
   * Change format of Slack notifications (by @eldano)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2015-12-04 21:45:42.000000000 +0100
+++ new/README.md       2016-01-07 22:21:05.000000000 +0100
@@ -7,26 +7,21 @@
 
 **THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY 
EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF 
EXCEPTION NOTIFICATION, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.**
 
--
-
-The Exception Notification gem provides a set of [notifiers](#notifiers) for 
sending notifications when errors occur in a Rack/Rails application.
-
-The built-in notifiers can deliver notifications by [email](#email-notifier), 
[campfire rooms](#campfire-notifier) or via [webhooks](#webhook-notifier).
+---
 
+The Exception Notification gem provides a set of [notifiers](#notifiers) for 
sending notifications when errors occur in a Rack/Rails application. The 
built-in notifiers can deliver notifications by [email](#email-notifier), 
[Campfire](#campfire-notifier), [HipChat](#hipchat-notifier), 
[Slack](#slack-notifier), [IRC](#irc-notifier) or via custom 
[WebHooks](#webhook-notifier).
 
 There's a great [Railscast about Exception 
Notification](http://railscasts.com/episodes/104-exception-notifications-revised)
 you can see that may help you getting started.
 
 [Follow us on Twitter](https://twitter.com/exception_notif) to get updates and 
notices about new releases.
 
-
 ## Requirements
 
-* Ruby 1.9.3 or greater
-* Rails 3.1 or greater, Sinatra or another Rack-based application.
+* Ruby 2.0 or greater
+* Rails 4.0 or greater, Sinatra or another Rack-based application.
 
 For previous releases, please checkout [this](#versions).
 
-
 ## Getting Started
 
 Add the following line to your application's Gemfile:
@@ -35,7 +30,9 @@
 gem 'exception_notification'
 ```
 
-As of Rails 3 ExceptionNotification is used as a rack middleware, or in the 
environment you want it to run. In most cases you would want 
ExceptionNotification to run on production. Thus, you can make it work by 
putting the following lines in your `config/environments/production.rb`:
+### Rails
+
+ExceptionNotification is used as a rack middleware, or in the environment you 
want it to run. In most cases you would want ExceptionNotification to run on 
production. Thus, you can make it work by putting the following lines in your 
`config/environments/production.rb`:
 
 ```ruby
 Rails.application.config.middleware.use ExceptionNotification::Rack,
@@ -46,24 +43,38 @@
   }
 ```
 
-> **Note**: In order to enable delivery notifications by email make sure you 
have [ActionMailer configured](#actionmailer-configuration).
+**Note**: In order to enable delivery notifications by email make sure you 
have [ActionMailer configured](#actionmailer-configuration).
 
+### Rack/Sinatra
 
 In order to use ExceptionNotification with Sinatra, please take a look in the 
[example 
application](https://github.com/smartinez87/exception_notification/tree/master/examples/sinatra).
 
+## Notifiers
+
+ExceptionNotification relies on notifiers to deliver notifications when errors 
occur in your applications. By default, six notifiers are available:
+
+* [Campfire notifier](#campfire-notifier)
+* [Email notifier](#email-notifier)
+* [HipChat notifier](#hipchat-notifier)
+* [IRC notifier](#irc-notifier)
+* [Slack notifier](#slack-notifier)
+* [WebHook notifier](#webhook-notifier)
 
-### Upgrading to 4.x version
+But, you also can easily implement your own [custom 
notifier](#custom-notifier).
 
-As of 4.x version the configuration syntax has changed. All email related 
options MUST BE nested under the `:email` key. Thus, previous configuration 
like:
+### Campfire notifier
+
+This notifier sends notifications to your Campfire room.
+
+#### Usage
+
+Just add the [tinder](https://github.com/collectiveidea/tinder) gem to your 
`Gemfile`:
 
 ```ruby
-Rails.application.config.middleware.use ExceptionNotifier,
-  :email_prefix => "[PREFIX] ",
-  :sender_address => %{"notifier" <notif...@example.com>},
-  :exception_recipients => %w{excepti...@example.com}
+gem 'tinder'
 ```
 
-becomes:
+To configure it, you need to set the `subdomain`, `token` and `room_name` 
options, like this:
 
 ```ruby
 Rails.application.config.middleware.use ExceptionNotification::Rack,
@@ -71,21 +82,42 @@
     :email_prefix => "[PREFIX] ",
     :sender_address => %{"notifier" <notif...@example.com>},
     :exception_recipients => %w{excepti...@example.com}
+  },
+  :campfire => {
+    :subdomain => 'my_subdomain',
+    :token => 'my_token',
+    :room_name => 'my_room'
   }
 ```
 
-Beside that, the rack middleware was renamed to `ExceptionNotification::Rack`.
+#### Options
 
-## Notifiers
+##### subdomain
 
-ExceptionNotification relies on notifiers to deliver notifications when errors 
occur in your applications. By default, three notifiers are available: [email 
notifier](#email-notifier), [campfire notifier](#campfire-notifier) and 
[webhook notifier](#webhook-notifier). But, you also can easily implement your 
own [custom notifier](#custom-notifier).
+*String, required*
 
+Your subdomain at Campfire.
+
+##### room_name
+
+*String, required*
+
+The Campfire room where the notifications must be published to.
+
+##### token
+
+*String, required*
+
+The API token to allow access to your Campfire account.
+
+
+For more options to set Campfire, like _ssl_, check 
[here](https://github.com/collectiveidea/tinder/blob/master/lib/tinder/campfire.rb#L17).
 
 ### Email notifier
 
 The Email notifier sends notifications by email. The notifications/emails sent 
includes information about the current request, session, and environment, and 
also gives a backtrace of the exception.
 
-After an exception notification has been delivered the rack environment 
variable 'exception_notifier.delivered' will be set to true.
+After an exception notification has been delivered the rack environment 
variable `exception_notifier.delivered` will be set to true.
 
 #### ActionMailer configuration
 
@@ -110,21 +142,18 @@
 
 Who the message is from.
 
-
 ##### exception_recipients
 
 *String/Array of strings, default: []*
 
 Who the message is destined for, can be a string of addresses, or an array of 
addresses.
 
-
 ##### email_prefix
 
 *String, default: [ERROR]*
 
 The subject's prefix of the message.
 
-
 ##### sections
 
 *Array of strings, default: %w(request session environment backtrace)*
@@ -174,7 +203,6 @@
 
 In the above case, `@document` and `@person` would be made available to the 
email renderer, allowing your new section(s) to access and display them. See 
the existing sections defined by the plugin for examples of how to write your 
own.
 
-
 ##### background_sections
 
 *Array of strings, default: %w(backtrace data)*
@@ -191,7 +219,6 @@
   }
 ```
 
-
 ##### email_headers
 
 *Hash of strings, default: {}*
@@ -208,28 +235,24 @@
   }
 ```
 
-
 ##### verbose_subject
 
 *Boolean, default: true*
 
 If enabled, include the exception message in the subject. Use 
`:verbose_subject => false` to exclude it.
 
-
 ##### normalize_subject
 
 *Boolean, default: false*
 
 If enabled, remove numbers from subject so they thread as a single one. Use 
`:normalize_subject => true` to enable it.
 
-
 ##### email_format
 
 *Symbol, default: :text*
 
 By default, ExceptionNotification sends emails in plain text, in order to 
sends multipart notifications (aka HTML emails) use `:email_format => :html`.
 
-
 ##### delivery_method
 
 *Symbol, default: :smtp*
@@ -267,73 +290,18 @@
 
 A complete list of `smtp_settings` options can be found in the [ActionMailer 
Configuration 
documentation](http://api.rubyonrails.org/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Configuration+options).
 
-
 ##### mailer_parent
 
 *String, default: ActionMailer::Base*
 
 The parent mailer which ExceptionNotification mailer inherit from.
 
-
 ##### deliver_with
 
 *Symbol, default: :deliver_now
 
 The method name to send emalis using ActionMailer.
 
-
-### Campfire notifier
-
-This notifier sends notifications to your Campfire room.
-
-#### Usage
-
-Just add the [tinder](https://github.com/collectiveidea/tinder) gem to your 
`Gemfile`:
-
-```ruby
-gem 'tinder'
-```
-
-To configure it, you need to set the `subdomain`, `token` and `room_name` 
options, like this:
-
-```ruby
-Rails.application.config.middleware.use ExceptionNotification::Rack,
-  :email => {
-    :email_prefix => "[PREFIX] ",
-    :sender_address => %{"notifier" <notif...@example.com>},
-    :exception_recipients => %w{excepti...@example.com}
-  },
-  :campfire => {
-    :subdomain => 'my_subdomain',
-    :token => 'my_token',
-    :room_name => 'my_room'
-  }
-```
-
-#### Options
-
-##### subdomain
-
-*String, required*
-
-Your subdomain at Campfire.
-
-##### room_name
-
-*String, required*
-
-The Campfire room where the notifications must be published to.
-
-##### token
-
-*String, required*
-
-The API token to allow access to your Campfire account.
-
-
-For more options to set Campfire, like _ssl_, check 
[here](https://github.com/collectiveidea/tinder/blob/master/lib/tinder/campfire.rb#L17).
-
-
 ### HipChat notifier
 
 This notifier sends notifications to your Hipchat room.
@@ -395,67 +363,6 @@
 
 For all options & possible values see [Hipchat 
API](https://www.hipchat.com/docs/api/method/rooms/message).
 
-### Webhook notifier
-
-This notifier ships notifications over the HTTP protocol.
-
-#### Usage
-
-Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your 
`Gemfile`:
-
-```ruby
-gem 'httparty'
-```
-
-To configure it, you need to set the `url` option, like this:
-
-```ruby
-Rails.application.config.middleware.use ExceptionNotification::Rack,
-  :email => {
-    :email_prefix => "[PREFIX] ",
-    :sender_address => %{"notifier" <notif...@example.com>},
-    :exception_recipients => %w{excepti...@example.com}
-  },
-  :webhook => {
-    :url => 'http://domain.com:5555/hubot/path'
-  }
-```
-
-By default, the WebhookNotifier will call the URLs using the POST method. But, 
you can change this using the `http_method` option.
-
-```ruby
-Rails.application.config.middleware.use ExceptionNotification::Rack,
-  :email => {
-    :email_prefix => "[PREFIX] ",
-    :sender_address => %{"notifier" <notif...@example.com>},
-    :exception_recipients => %w{excepti...@example.com}
-  },
-  :webhook => {
-    :url => 'http://domain.com:5555/hubot/path',
-    :http_method => :get
-  }
-```
-
-Besides the `url` and `http_method` options, all the other options are passed 
directly to HTTParty. Thus, if the HTTP server requires authentication, you can 
include the following options:
-
-```ruby
-Rails.application.config.middleware.use ExceptionNotification::Rack,
-  :email => {
-    :email_prefix => "[PREFIX] ",
-    :sender_address => %{"notifier" <notif...@example.com>},
-    :exception_recipients => %w{excepti...@example.com}
-  },
-  :webhook => {
-    :url => 'http://domain.com:5555/hubot/path',
-    :basic_auth => {
-      :username => 'alice',
-      :password => 'password'
-    }
-  }
-```
-
-For more HTTParty options, check out the 
[documentation](https://github.com/jnunemaker/httparty).
-
 ### IRC notifier
 
 This notifier sends notifications to an IRC channel using the carrier-pigeon 
gem.
@@ -638,6 +545,68 @@
 
 Contains additional payload for a message (e.g avatar, attachments, etc). See 
[slack-notifier](https://github.com/stevenosloan/slack-notifier#additional-parameters)
 for more information.. Default: '{}'
 
+
+### WebHook notifier
+
+This notifier ships notifications over the HTTP protocol.
+
+#### Usage
+
+Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your 
`Gemfile`:
+
+```ruby
+gem 'httparty'
+```
+
+To configure it, you need to set the `url` option, like this:
+
+```ruby
+Rails.application.config.middleware.use ExceptionNotification::Rack,
+  :email => {
+    :email_prefix => "[PREFIX] ",
+    :sender_address => %{"notifier" <notif...@example.com>},
+    :exception_recipients => %w{excepti...@example.com}
+  },
+  :webhook => {
+    :url => 'http://domain.com:5555/hubot/path'
+  }
+```
+
+By default, the WebhookNotifier will call the URLs using the POST method. But, 
you can change this using the `http_method` option.
+
+```ruby
+Rails.application.config.middleware.use ExceptionNotification::Rack,
+  :email => {
+    :email_prefix => "[PREFIX] ",
+    :sender_address => %{"notifier" <notif...@example.com>},
+    :exception_recipients => %w{excepti...@example.com}
+  },
+  :webhook => {
+    :url => 'http://domain.com:5555/hubot/path',
+    :http_method => :get
+  }
+```
+
+Besides the `url` and `http_method` options, all the other options are passed 
directly to HTTParty. Thus, if the HTTP server requires authentication, you can 
include the following options:
+
+```ruby
+Rails.application.config.middleware.use ExceptionNotification::Rack,
+  :email => {
+    :email_prefix => "[PREFIX] ",
+    :sender_address => %{"notifier" <notif...@example.com>},
+    :exception_recipients => %w{excepti...@example.com}
+  },
+  :webhook => {
+    :url => 'http://domain.com:5555/hubot/path',
+    :basic_auth => {
+      :username => 'alice',
+      :password => 'password'
+    }
+  }
+```
+
+For more HTTParty options, check out the 
[documentation](https://github.com/jnunemaker/httparty).
+
 ### Custom notifier
 
 Simply put, notifiers are objects which respond to `#call(exception, options)` 
method. Thus, a lambda can be used as a notifier as follow:
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/exception_notification.gemspec 
new/exception_notification.gemspec
--- old/exception_notification.gemspec  2015-12-04 21:45:42.000000000 +0100
+++ new/exception_notification.gemspec  2016-01-07 22:21:05.000000000 +0100
@@ -1,8 +1,7 @@
 Gem::Specification.new do |s|
   s.name = 'exception_notification'
-  s.version = '4.1.2'
+  s.version = '4.1.4'
   s.authors = ["Jamis Buck", "Josh Peek"]
-  s.date = %q{2015-12-04}
   s.summary = "Exception notification for Rails apps"
   s.homepage = "http://smartinez87.github.com/exception_notification";
   s.email = "smartine...@gmail.com"
@@ -21,7 +20,7 @@
 
   s.add_development_dependency "rails", "~> 4.0"
   s.add_development_dependency "resque", "~> 1.2.0"
-  # Sidekiq 3.2.2 does not support Ruby 1.9. 
+  # Sidekiq 3.2.2 does not support Ruby 1.9.
   s.add_development_dependency "sidekiq", "~> 3.0.0", "< 3.2.2"
   s.add_development_dependency "tinder", "~> 1.8"
   s.add_development_dependency "httparty", "~> 0.10.2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/base_notifier.rb 
new/lib/exception_notifier/base_notifier.rb
--- old/lib/exception_notifier/base_notifier.rb 1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/exception_notifier/base_notifier.rb 2016-01-07 22:21:05.000000000 
+0100
@@ -0,0 +1,25 @@
+module ExceptionNotifier
+  class BaseNotifier
+    attr_accessor :base_options
+
+    def initialize(options={})
+      @base_options = options
+    end
+
+    def send_notice(exception, options, message, message_opts=nil)
+      _pre_callback(exception, options, message, message_opts)
+      result = yield(message, message_opts)
+      _post_callback(exception, options, message, message_opts)
+      result
+    end
+
+    def _pre_callback(exception, options, message, message_opts)
+      @base_options[:pre_callback].call(options, self, exception.backtrace, 
message, message_opts) if @base_options[:pre_callback].respond_to?(:call)
+    end
+
+    def _post_callback(exception, options, message, message_opts)
+      @base_options[:post_callback].call(options, self, exception.backtrace, 
message, message_opts) if @base_options[:post_callback].respond_to?(:call)
+    end
+
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/campfire_notifier.rb 
new/lib/exception_notifier/campfire_notifier.rb
--- old/lib/exception_notifier/campfire_notifier.rb     2015-12-04 
21:45:42.000000000 +0100
+++ new/lib/exception_notifier/campfire_notifier.rb     2016-01-07 
22:21:05.000000000 +0100
@@ -1,11 +1,12 @@
 module ExceptionNotifier
-  class CampfireNotifier
+  class CampfireNotifier < BaseNotifier
 
     attr_accessor :subdomain
     attr_accessor :token
     attr_accessor :room
 
     def initialize(options)
+      super
       begin
         subdomain = options.delete(:subdomain)
         room_name = options.delete(:room_name)
@@ -20,7 +21,9 @@
       if active?
         message = "A new exception occurred: '#{exception.message}'"
         message += " on '#{exception.backtrace.first}'" if exception.backtrace
-        @room.paste message message
+        send_notice(exception, options, message) do |msg, _|
+          @room.paste msg
+        end
       end
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/email_notifier.rb 
new/lib/exception_notifier/email_notifier.rb
--- old/lib/exception_notifier/email_notifier.rb        2015-12-04 
21:45:42.000000000 +0100
+++ new/lib/exception_notifier/email_notifier.rb        2016-01-07 
22:21:05.000000000 +0100
@@ -4,7 +4,9 @@
 require 'pp'
 
 module ExceptionNotifier
-  class EmailNotifier < Struct.new(:sender_address, :exception_recipients,
+  class EmailNotifier < BaseNotifier
+    attr_accessor(:sender_address, :exception_recipients,
+    :pre_callback, :post_callback,
     :email_prefix, :email_format, :sections, :background_sections,
     :verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
     :email_headers, :mailer_parent, :template_path, :deliver_with)
@@ -78,6 +80,12 @@
             end
           end
 
+          helper_method :safe_encode
+
+          def safe_encode(value)
+            value.encode("utf-8", invalid: :replace, undef: :replace, replace: 
"_")
+          end
+
           def html_mail?
             @options[:email_format] == :html
           end
@@ -115,20 +123,22 @@
     end
 
     def initialize(options)
+      super
       delivery_method = (options[:delivery_method] || :smtp)
       mailer_settings_key = "#{delivery_method}_settings".to_sym
       options[:mailer_settings] = options.delete(mailer_settings_key)
 
-      super(*options.reverse_merge(EmailNotifier.default_options).values_at(
+      options.reverse_merge(EmailNotifier.default_options).select{|k,v|[
         :sender_address, :exception_recipients,
+        :pre_callback, :post_callback,
         :email_prefix, :email_format, :sections, :background_sections,
         :verbose_subject, :normalize_subject, :delivery_method, 
:mailer_settings,
-        :email_headers, :mailer_parent, :template_path, :deliver_with))
+        :email_headers, :mailer_parent, :template_path, 
:deliver_with].include?(k)}.each{|k,v| send("#{k}=", v)}
     end
 
     def options
       @options ||= {}.tap do |opts|
-        each_pair { |k,v| opts[k] = v }
+        self.instance_variables.each { |var| opts[var[1..-1].to_sym] = 
self.instance_variable_get(var) }
       end
     end
 
@@ -147,9 +157,13 @@
       env = options[:env]
       default_options = self.options
       if env.nil?
-        mailer.background_exception_notification(exception, options, 
default_options)
+        send_notice(exception, options, nil, default_options) do |_, 
default_opts|
+          mailer.background_exception_notification(exception, options, 
default_opts)
+        end
       else
-        mailer.exception_notification(env, exception, options, default_options)
+        send_notice(exception, options, nil, default_options) do |_, 
default_opts|
+          mailer.exception_notification(env, exception, options, default_opts)
+        end
       end
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/hipchat_notifier.rb 
new/lib/exception_notifier/hipchat_notifier.rb
--- old/lib/exception_notifier/hipchat_notifier.rb      2015-12-04 
21:45:42.000000000 +0100
+++ new/lib/exception_notifier/hipchat_notifier.rb      2016-01-07 
22:21:05.000000000 +0100
@@ -1,11 +1,12 @@
 module ExceptionNotifier
-  class HipchatNotifier
+  class HipchatNotifier < BaseNotifier
 
     attr_accessor :from
     attr_accessor :room
     attr_accessor :message_options
 
     def initialize(options)
+      super
       begin
         api_token         = options.delete(:api_token)
         room_name         = options.delete(:room_name)
@@ -15,7 +16,7 @@
         @from             = options.delete(:from) || 'Exception'
         @room             = HipChat::Client.new(api_token, opts)[room_name]
         @message_template = options.delete(:message_template) || ->(exception) 
{
-          msg = "A new exception occurred: '#{exception.message}'"
+          msg = "A new exception occurred: 
'#{Rack::Utils.escape_html(exception.message)}'"
           msg += " on '#{exception.backtrace.first}'" if exception.backtrace
           msg
         }
@@ -30,7 +31,9 @@
       return if !active?
 
       message = @message_template.call(exception)
-      @room.send(@from, message, @message_options)
+      send_notice(exception, options, message, @message_options) do |msg, 
message_opts|
+        @room.send(@from, msg, message_opts)
+      end
     end
 
     private
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/irc_notifier.rb 
new/lib/exception_notifier/irc_notifier.rb
--- old/lib/exception_notifier/irc_notifier.rb  2015-12-04 21:45:42.000000000 
+0100
+++ new/lib/exception_notifier/irc_notifier.rb  2016-01-07 22:21:05.000000000 
+0100
@@ -1,6 +1,7 @@
 module ExceptionNotifier
-  class IrcNotifier
+  class IrcNotifier < BaseNotifier
     def initialize(options)
+      super
       @config = OpenStruct.new
       parse_options(options)
     end
@@ -8,7 +9,11 @@
     def call(exception, options={})
       message = "'#{exception.message}'"
       message += " on '#{exception.backtrace.first}'" if exception.backtrace
-      send_message([*@config.prefix, *message].join(' ')) if active?
+      if active?
+        send_notice(exception, options, message) do |msg, _|
+          send_message([*@config.prefix, *msg].join(' '))
+        end
+      end
     end
 
     def send_message(message)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/slack_notifier.rb 
new/lib/exception_notifier/slack_notifier.rb
--- old/lib/exception_notifier/slack_notifier.rb        2015-12-04 
21:45:42.000000000 +0100
+++ new/lib/exception_notifier/slack_notifier.rb        2016-01-07 
22:21:05.000000000 +0100
@@ -1,10 +1,11 @@
 module ExceptionNotifier
-  class SlackNotifier
+  class SlackNotifier < BaseNotifier
     include ExceptionNotifier::BacktraceCleaner
 
     attr_accessor :notifier
 
     def initialize(options)
+      super
       begin
         @ignore_data_if = options[:ignore_data_if]
 
@@ -38,7 +39,11 @@
 
       attchs = [color: 'danger', text: text, fields: fields, mrkdwn_in: 
%w(text fields)]
 
-      @notifier.ping '', @message_opts.merge(attachments: attchs) if valid?
+      if valid?
+        send_notice(exception, options, clean_message, 
@message_opts.merge(attachments: attchs)) do |msg, message_opts| 
+          @notifier.ping '', message_opts
+        end
+      end
     end
 
     protected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/exception_notifier/views/exception_notifier/_environment.text.erb 
new/lib/exception_notifier/views/exception_notifier/_environment.text.erb
--- old/lib/exception_notifier/views/exception_notifier/_environment.text.erb   
2015-12-04 21:45:42.000000000 +0100
+++ new/lib/exception_notifier/views/exception_notifier/_environment.text.erb   
2016-01-07 22:21:05.000000000 +0100
@@ -1,5 +1,5 @@
 <% filtered_env = @request.filtered_env -%>
 <% max = filtered_env.keys.map(&:to_s).max { |a, b| a.length <=> b.length } -%>
 <% filtered_env.keys.map(&:to_s).sort.each do |key| -%>
-* <%= raw("%-*s: %s" % [max.length, key, inspect_object(filtered_env[key])]) %>
+* <%= raw safe_encode("%-*s: %s" % [max.length, key, 
inspect_object(filtered_env[key])]) %>
 <% end -%>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/exception_notifier/views/exception_notifier/_request.text.erb 
new/lib/exception_notifier/views/exception_notifier/_request.text.erb
--- old/lib/exception_notifier/views/exception_notifier/_request.text.erb       
2015-12-04 21:45:42.000000000 +0100
+++ new/lib/exception_notifier/views/exception_notifier/_request.text.erb       
2016-01-07 22:21:05.000000000 +0100
@@ -1,7 +1,7 @@
-* URL        : <%= raw @request.url %>
+* URL        : <%= raw safe_encode @request.url %>
 * HTTP Method: <%= raw @request.request_method %>
 * IP address : <%= raw @request.remote_ip %>
-* Parameters : <%= raw @request.filtered_parameters.inspect %>
+* Parameters : <%= raw safe_encode @request.filtered_parameters.inspect %>
 * Timestamp  : <%= raw Time.current %>
 * Server : <%= raw Socket.gethostname %>
 <% if defined?(Rails) && Rails.respond_to?(:root) %>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier/webhook_notifier.rb 
new/lib/exception_notifier/webhook_notifier.rb
--- old/lib/exception_notifier/webhook_notifier.rb      2015-12-04 
21:45:42.000000000 +0100
+++ new/lib/exception_notifier/webhook_notifier.rb      2016-01-07 
22:21:05.000000000 +0100
@@ -1,9 +1,10 @@
 require 'action_dispatch'
 
 module ExceptionNotifier
-  class WebhookNotifier
+  class WebhookNotifier < BaseNotifier
 
     def initialize(options)
+      super
       @default_options = options
     end
 
@@ -23,7 +24,7 @@
       options[:body][:exception] = {:error_class => exception.class.to_s,
                                     :message => exception.message.inspect,
                                     :backtrace => exception.backtrace}
-      options[:body][:data] = (env['exception_notifier.exception_data'] || 
{}).merge(options[:data] || {})
+      options[:body][:data] = (env && env['exception_notifier.exception_data'] 
|| {}).merge(options[:data] || {})
 
       unless env.nil?
         request = ActionDispatch::Request.new(env)
@@ -38,8 +39,9 @@
         options[:body][:session] = request.session
         options[:body][:environment] = request.filtered_env
       end
-
-      HTTParty.send(http_method, url, options)
+      send_notice(exception, options, nil, @default_options) do |msg, opts|
+        HTTParty.send(http_method, url, opts)
+      end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/exception_notifier.rb 
new/lib/exception_notifier.rb
--- old/lib/exception_notifier.rb       2015-12-04 21:45:42.000000000 +0100
+++ new/lib/exception_notifier.rb       2016-01-07 22:21:05.000000000 +0100
@@ -1,6 +1,7 @@
 require 'logger'
 require 'active_support/core_ext/string/inflections'
 require 'active_support/core_ext/module/attribute_accessors'
+require 'exception_notifier/base_notifier'
 
 module ExceptionNotifier
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-12-04 21:45:42.000000000 +0100
+++ new/metadata        2016-01-07 22:21:05.000000000 +0100
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: exception_notification
 version: !ruby/object:Gem::Version
-  version: 4.1.2
+  version: 4.1.4
 platform: ruby
 authors:
 - Jamis Buck
@@ -9,7 +9,7 @@
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2015-12-04 00:00:00.000000000 Z
+date: 2016-01-07 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: actionmailer
@@ -242,6 +242,7 @@
 - lib/exception_notification/resque.rb
 - lib/exception_notification/sidekiq.rb
 - lib/exception_notifier.rb
+- lib/exception_notifier/base_notifier.rb
 - lib/exception_notifier/campfire_notifier.rb
 - lib/exception_notifier/email_notifier.rb
 - lib/exception_notifier/hipchat_notifier.rb
@@ -353,7 +354,7 @@
       version: 1.8.11
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.4.5
+rubygems_version: 2.4.5.1
 signing_key: 
 specification_version: 4
 summary: Exception notification for Rails apps
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/dummy/config/environment.rb 
new/test/dummy/config/environment.rb
--- old/test/dummy/config/environment.rb        2015-12-04 21:45:42.000000000 
+0100
+++ new/test/dummy/config/environment.rb        2016-01-07 22:21:05.000000000 
+0100
@@ -8,7 +8,9 @@
     :exception_recipients => %w{dummyexcepti...@example.com},
     :email_headers => { "X-Custom-Header" => "foobar" },
     :sections => ['new_section', 'request', 'session', 'environment', 
'backtrace'],
-    :background_sections => %w(new_bkg_section backtrace data)
+    :background_sections => %w(new_bkg_section backtrace data),
+    :pre_callback => proc { |opts, notifier, backtrace, message, message_opts| 
message_opts[:pre_callback_called] = 1 },
+    :post_callback => proc { |opts, notifier, backtrace, message, 
message_opts| message_opts[:post_callback_called] = 1 }
   }
 
 # Initialize the rails application
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/campfire_notifier_test.rb 
new/test/exception_notifier/campfire_notifier_test.rb
--- old/test/exception_notifier/campfire_notifier_test.rb       2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/campfire_notifier_test.rb       2016-01-07 
22:21:05.000000000 +0100
@@ -46,6 +46,30 @@
     assert_nil campfire.call(fake_exception)
   end
 
+  test "should call pre/post_callback if specified" do 
+    pre_callback_called, post_callback_called = 0,0
+    Tinder::Campfire.stubs(:new).returns(Object.new)
+
+    campfire = ExceptionNotifier::CampfireNotifier.new(
+      {
+        :subdomain => 'test',
+        :token => 'test_token',
+        :room_name => 'test_room',
+        :pre_callback => proc { |opts, notifier, backtrace, message, 
message_opts|
+          pre_callback_called += 1
+        },
+        :post_callback => proc { |opts, notifier, backtrace, message, 
message_opts|
+          post_callback_called += 1
+        }
+      }
+    )
+    campfire.room = Object.new
+    campfire.room.stubs(:paste).returns(fake_notification)
+    campfire.call(fake_exception)
+    assert_equal(1, pre_callback_called)
+    assert_equal(1, post_callback_called)
+  end
+
   private
 
   def fake_notification
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/email_notifier_test.rb 
new/test/exception_notifier/email_notifier_test.rb
--- old/test/exception_notifier/email_notifier_test.rb  2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/email_notifier_test.rb  2016-01-07 
22:21:05.000000000 +0100
@@ -13,6 +13,11 @@
     end
   end
 
+  test "should call pre/post_callback if specified" do
+    assert_equal @email_notifier.options[:pre_callback_called], 1
+    assert_equal @email_notifier.options[:post_callback_called], 1
+  end
+
   test "should have default sender address overridden" do
     assert_equal @email_notifier.sender_address, %("Dummy Notifier" 
<dummynotif...@example.com>)
   end
@@ -150,6 +155,26 @@
     assert_nil @ignored_mail
   end
 
+  test "should encode environment strings" do
+    email_notifier = ExceptionNotifier::EmailNotifier.new(
+      :sender_address => "<dummynotif...@example.com>",
+      :exception_recipients => %w{dummyexcepti...@example.com},
+      :deliver_with => :deliver_now
+    )
+
+    mail = email_notifier.create_email(
+      @exception,
+      :env => {
+        "REQUEST_METHOD" => "GET",
+        "rack.input" => "",
+        "invalid_encoding" => 
"R\xC3\xA9sum\xC3\xA9".force_encoding(Encoding::ASCII),
+      },
+      :email_format => :text
+    )
+
+    assert_match /invalid_encoding\s+: R__sum__/, mail.encoded
+  end
+
   if defined?(Rails) && ('4.2'...'5.0').cover?(Rails.version)
     test "should be able to specify ActionMailer::MessageDelivery method" do
       email_notifier = ExceptionNotifier::EmailNotifier.new(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/hipchat_notifier_test.rb 
new/test/exception_notifier/hipchat_notifier_test.rb
--- old/test/exception_notifier/hipchat_notifier_test.rb        2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/hipchat_notifier_test.rb        2016-01-07 
22:21:05.000000000 +0100
@@ -16,6 +16,24 @@
     hipchat.call(fake_exception)
   end
 
+  test "should call pre/post_callback if specified" do
+    pre_callback_called, post_callback_called = 0,0
+    options = {
+      :api_token => 'good_token',
+      :room_name => 'room_name',
+      :color     => 'yellow',
+      :pre_callback => proc { |*| pre_callback_called += 1},
+      :post_callback => proc { |*| post_callback_called += 1}
+    }
+
+    HipChat::Room.any_instance.expects(:send).with('Exception', fake_body, { 
:color => 'yellow' }.merge(options.except(:api_token, :room_name)))
+
+    hipchat = ExceptionNotifier::HipchatNotifier.new(options)
+    hipchat.call(fake_exception)
+    assert_equal(1, pre_callback_called)
+    assert_equal(1, post_callback_called)
+  end
+
   test "should send hipchat notification without backtrace info if properly 
configured" do
     options = {
       :api_token => 'good_token',
@@ -86,6 +104,22 @@
     hipchat.call(fake_exception)
   end
 
+  test "should send hipchat notification with HTML-escaped meessage if using 
default message_template" do
+    options = {
+      :api_token => 'good_token',
+      :room_name => 'room_name',
+      :color     => 'yellow',
+    }
+
+    exception = fake_exception_with_html_characters
+    body = "A new exception occurred: 
'#{Rack::Utils.escape_html(exception.message)}' on 
'#{exception.backtrace.first}'"
+
+    HipChat::Room.any_instance.expects(:send).with('Exception', body, { :color 
=> 'yellow' })
+
+    hipchat = ExceptionNotifier::HipchatNotifier.new(options)
+    hipchat.call(exception)
+  end
+
   test "should use APIv1 if api_version is not specified" do
     options = {
       :api_token => 'good_token',
@@ -123,6 +157,14 @@
     rescue Exception => e
       e
     end
+  end
+
+  def fake_exception_with_html_characters
+    exception = begin
+      raise StandardError.new('an error with <html> characters')
+    rescue Exception => e
+      e
+    end
   end
 
   def fake_body_without_backtrace
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/irc_notifier_test.rb 
new/test/exception_notifier/irc_notifier_test.rb
--- old/test/exception_notifier/irc_notifier_test.rb    2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/irc_notifier_test.rb    2016-01-07 
22:21:05.000000000 +0100
@@ -16,6 +16,25 @@
     irc.call(fake_exception)
   end
 
+  test "should call pre/post_callback if specified" do
+    pre_callback_called, post_callback_called = 0,0
+
+    options = {
+      :domain => 'irc.example.com',
+      :pre_callback => proc { |*| pre_callback_called += 1},
+      :post_callback => proc { |*| post_callback_called += 1}
+    }
+
+    CarrierPigeon.expects(:send).with(has_key(:uri)) do |v|
+      /divided by 0/.match(v[:message])
+    end
+
+    irc = ExceptionNotifier::IrcNotifier.new(options)
+    irc.call(fake_exception)
+    assert_equal(1, pre_callback_called)
+    assert_equal(1, post_callback_called)
+  end
+
   test "should send irc notification without backtrace info if properly 
configured" do
     options = {
       :domain => 'irc.example.com'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/slack_notifier_test.rb 
new/test/exception_notifier/slack_notifier_test.rb
--- old/test/exception_notifier/slack_notifier_test.rb  2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/slack_notifier_test.rb  2016-01-07 
22:21:05.000000000 +0100
@@ -110,6 +110,35 @@
     slack_notifier.call(@exception, notification_options)
   end
 
+  test "should call pre/post_callback proc if specified" do
+    post_callback_called = 0
+    options = {
+      webhook_url: "http://slack.webhook.url";,
+      username: "test",
+      custom_hook: "hook",
+      :pre_callback => proc { |opts, notifier, backtrace, message, 
message_opts|
+        (message_opts[:attachments] = []) << { text: 
"#{backtrace.join("\n")}", color: 'danger' }
+      },
+      :post_callback => proc { |opts, notifier, backtrace, message, 
message_opts|
+        post_callback_called = 1
+      },
+      additional_parameters: {
+        icon_url: "icon",
+      }
+    }
+
+    Slack::Notifier.any_instance.expects(:ping).with('',
+                                                     {:icon_url => 'icon',
+                                                      :attachments => [
+                                                        {:text => "backtrace 
line 1\nbacktrace line 2",
+                                                         :color => 'danger'}
+                                                     ]})
+
+    slack_notifier = ExceptionNotifier::SlackNotifier.new(options)
+    slack_notifier.call(@exception)
+    assert_equal(post_callback_called, 1)
+  end
+
   private
 
   def fake_exception
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier/webhook_notifier_test.rb 
new/test/exception_notifier/webhook_notifier_test.rb
--- old/test/exception_notifier/webhook_notifier_test.rb        2015-12-04 
21:45:42.000000000 +0100
+++ new/test/exception_notifier/webhook_notifier_test.rb        2016-01-07 
22:21:05.000000000 +0100
@@ -25,6 +25,12 @@
     assert response[:body][:data][:extra_data].has_key?(:data_item1)
   end
 
+  test "should call pre/post_callback if specified" do
+    HTTParty.stubs(:send).returns(fake_response)
+    webhook = ExceptionNotifier::WebhookNotifier.new({:url => 
'http://localhost:8000'})
+    webhook.call(fake_exception)
+  end
+
   private
 
   def fake_response
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/exception_notifier_test.rb 
new/test/exception_notifier_test.rb
--- old/test/exception_notifier_test.rb 2015-12-04 21:45:42.000000000 +0100
+++ new/test/exception_notifier_test.rb 2016-01-07 22:21:05.000000000 +0100
@@ -98,4 +98,5 @@
 
     ExceptionNotifier.unregister_exception_notifier(:test)
   end
+
 end


Reply via email to