Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit c08a391

Browse files
committed
Dont show non-utf8-able values
1 parent b9a0dff commit c08a391

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/controllers/forest_liana/application_controller.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def force_utf8_attributes_encoding(model)
120120
model['attributes'].each do |name, value|
121121
if value.respond_to?(:force_encoding)
122122
begin
123-
model['attributes'][name] = value.force_encoding('utf-8')
123+
encoded_value = value.force_encoding('utf-8')
124+
encoded_value = value.encode!('utf-8', invalid: :replace, undef: :replace, replace: '?')
125+
model['attributes'][name] = encoded_value.valid_encoding? ? encoded_value : nil
124126
rescue
125127
# NOTICE: Enums are frozen Strings
126128
end

0 commit comments

Comments
 (0)