File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ def process(value)
55 value . map { |v | process v }
66 elsif value . is_a? Hash
77 value . merge ( value ) { |_ , v | process v }
8+ elsif value . is_a? ( Exception ) && !value . message . valid_encoding?
9+ clean_exc = value . class . new ( clean_invalid_utf8_bytes ( value . message ) )
10+ clean_exc . set_backtrace ( value . backtrace )
11+ clean_exc
812 else
913 clean_invalid_utf8_bytes ( value )
1014 end
Original file line number Diff line number Diff line change 2424 expect ( results [ 'invalid' ] ) . to eq ( "invalid utf8 string goes here" )
2525 end
2626
27+ it "should cleanup invalid UTF-8 bytes in Exception messages" do
28+ data = Exception . new ( "invalid utf8 string goes here\255 " . force_encoding ( 'UTF-8' ) )
29+
30+ results = @processor . process ( data )
31+ expect ( results . message ) . to eq ( "invalid utf8 string goes here" )
32+ end
33+
2734 it 'should keep valid UTF-8 bytes after cleaning' do
2835 data = { }
2936 data [ 'invalid' ] = "한국, 中國, 日本(にっぽん)\255 " . force_encoding ( 'UTF-8' )
You can’t perform that action at this time.
0 commit comments