Permalink
Browse files

Merge commit 'v2.4.8'

* commit 'v2.4.8':
  Bumping to version 2.4.8
  Prevent recursive data structures
  Bumping to version 2.4.7
  Specify ./config/boot for 1.9.2's sake
  Bumping to version 2.4.6
  Modify the body in place, don't replace the array.
  • Loading branch information...
2 parents 54c530c + 2f484b5 commit 294076453a77791eb3895d9c9b3b3ae68d5f9628 @cee-dub cee-dub committed Mar 25, 2011
View
@@ -1,3 +1,21 @@
+Version 2.4.8 - Mon Mar 21 11:11:16 -0400 2011
+===============================================================================
+
+Jonathan Yurek(1):
+ Prevent infinite loops from recursive data structures.
+
+Version 2.4.7 - Thu Mar 10 16:21:31 -0500 2011
+===============================================================================
+
+Jonathan Yurek(1):
+ Rails generator requires './config/boot' for 1.9.2 compatibility.
+
+Version 2.4.6 - Tue Feb 15 15:51:17 -0500 2011
+===============================================================================
+
+Jonathan Yurek(1):
+ Modify the error page's body in-place.
+
Version 2.4.5 - Wed Feb 02 13:24:29 -0500 2011
===============================================================================
@@ -393,6 +411,9 @@ Nick Quaranto (3):
+
+
+
@@ -226,14 +226,16 @@ def clean_unserializable_data_from(attribute)
# Removes non-serializable data. Allowed data types are strings, arrays,
# and hashes. All other types are converted to strings.
# TODO: move this onto Hash
- def clean_unserializable_data(data)
+ def clean_unserializable_data(data, stack = [])
+ return "[possible infinite recursion halted]" if stack.any?{|item| item == data.object_id }
+
if data.respond_to?(:to_hash)
data.to_hash.inject({}) do |result, (key, value)|
- result.merge(key => clean_unserializable_data(value))
+ result.merge(key => clean_unserializable_data(value, stack + [data.object_id]))
end
elsif data.respond_to?(:to_ary)
data.collect do |value|
- clean_unserializable_data(value)
+ clean_unserializable_data(value, stack + [data.object_id])
end
else
data.to_s
@@ -9,20 +9,14 @@ def replacement(with)
end
def call(env)
- response = @app.call(env)
+ status, headers, body = @app.call(env)
if env['hoptoad.error_id']
- new_response = []
- original_content_length = 0
- modified_content_length = 0
- response[2].each do |chunk|
- original_content_length += chunk.length
- new_response << chunk.to_s.gsub("<!-- HOPTOAD ERROR -->", replacement(env['hoptoad.error_id']))
- modified_content_length += new_response.last.length
+ body.each_with_index do |chunk, i|
+ body[i] = chunk.to_s.gsub("<!-- HOPTOAD ERROR -->", replacement(env['hoptoad.error_id']))
end
- response[1]['Content-Length'] = modified_content_length.to_s
- response[2] = new_response
+ headers['Content-Length'] = body.sum(&:length).to_s
end
- response
+ [status, headers, body]
end
end
end
@@ -1,3 +1,3 @@
module HoptoadNotifier
- VERSION = "2.4.5".freeze
+ VERSION = "2.4.8".freeze
end
@@ -38,7 +38,7 @@ def append_capistrano_hook
if File.exists?('config/deploy.rb') && File.exists?('Capfile')
append_file('config/deploy.rb', <<-HOOK)
- require 'config/boot'
+ require './config/boot'
require 'hoptoad_notifier/capistrano'
HOOK
end
View
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/helper'
+
+class RecursionTest < Test::Unit::TestCase
+ should "not allow infinite recursion" do
+ hash = {:a => :a}
+ hash[:hash] = hash
+ notice = HoptoadNotifier::Notice.new(:parameters => hash)
+ assert_equal "[possible infinite recursion halted]", notice.parameters[:hash]
+ end
+end
@@ -4,7 +4,7 @@ class UserInformerTest < Test::Unit::TestCase
should "modify output if there is a hoptoad id" do
main_app = lambda do |env|
env['hoptoad.error_id'] = 1
- [200, {}, "<!-- HOPTOAD ERROR -->"]
+ [200, {}, ["<!-- HOPTOAD ERROR -->"]]
end
informer_app = HoptoadNotifier::UserInformer.new(main_app)
@@ -17,7 +17,7 @@ class UserInformerTest < Test::Unit::TestCase
should "not modify output if there is no hoptoad id" do
main_app = lambda do |env|
- [200, {}, "<!-- HOPTOAD ERROR -->"]
+ [200, {}, ["<!-- HOPTOAD ERROR -->"]]
end
informer_app = HoptoadNotifier::UserInformer.new(main_app)

0 comments on commit 2940764

Please sign in to comment.