Skip to content

Commit

Permalink
Make arg display a little more paranoid, fixes sidekiq#2405
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jun 26, 2015
1 parent dfa2b44 commit e41257e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
HEAD
-----------

- Safer display of job data in Web UI [#2405]

3.4.1
-----------

Expand Down
15 changes: 13 additions & 2 deletions lib/sidekiq/web_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,22 @@ def truncate(text, truncate_after_chars = 2000)

def display_args(args, truncate_after_chars = 2000)
args.map do |arg|
a = arg.inspect
h(truncate(a))
h(truncate(to_display(arg)))
end.join(", ")
end

def to_display(arg)
begin
arg.inspect
rescue
begin
arg.to_s
rescue => ex
"Cannot display argument: [#{ex.class.name}] #{ex.message}"
end
end
end

RETRY_JOB_KEYS = Set.new(%w(
queue class args retry_count retried_at failed_at
jid error_message error_class backtrace
Expand Down

0 comments on commit e41257e

Please sign in to comment.