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

Sidekiq Web: If text contains invalid byte sequence, replace them instead of raising an exception

This commit is contained in:
David Leung 2013-11-01 16:17:15 -07:00
parent 7c22a1deb5
commit 318f4eb719

View file

@ -160,6 +160,10 @@ module Sidekiq
def h(text)
::Rack::Utils.escape_html(text)
rescue ArgumentError => e
raise unless e.message.eql?('invalid byte sequence in UTF-8')
text.encode!('UTF-16', 'UTF-8', invalid: :replace, replace: '').encode!('UTF-8', 'UTF-16')
retry
end
# Any paginated list that performs an action needs to redirect