1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Better handling of malformed job arguments in payload, fixes #4095

This commit is contained in:
Mike Perham 2019-02-08 08:53:23 -08:00
parent f72d68faec
commit d911036768
4 changed files with 28 additions and 4 deletions

View file

@ -2,6 +2,11 @@
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
HEAD
---------
- Better handling of malformed job arguments in payload [#4095]
5.2.5
---------

View file

@ -1,4 +1,4 @@
# frozen_string_literal: true
module Sidekiq
VERSION = "5.2.5"
VERSION = "5.2.6"
end

View file

@ -207,9 +207,16 @@ module Sidekiq
end
def display_args(args, truncate_after_chars = 2000)
args.map do |arg|
h(truncate(to_display(arg), truncate_after_chars))
end.join(", ")
return "Invalid job payload, args is nil" if args == nil
return "Invalid job payload, args must be an Array, not #{args.class.name}" if !args.is_a?(Array)
begin
args.map do |arg|
h(truncate(to_display(arg), truncate_after_chars))
end.join(", ")
rescue
"Illegal job arguments: #{h args.inspect}"
end
end
def csrf_tag

View file

@ -95,4 +95,16 @@ class TestWebHelpers < Minitest::Test
)
assert_equal expected, obj.available_locales.sort
end
def test_display_illegal_args
o = Helpers.new
s = o.display_args([1,2,3])
assert_equal "1, 2, 3", s
s = o.display_args(["<html>", 12])
assert_equal "&quot;&lt;html&gt;&quot;, 12", s
s = o.display_args("<html>")
assert_equal "Invalid job payload, args must be an Array, not String", s
s = o.display_args(nil)
assert_equal "Invalid job payload, args is nil", s
end
end