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

Commit 0c72a97

Browse files
committed
Dont show non-utf8-able values
1 parent 60476a1 commit 0c72a97

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
@@ -118,7 +118,9 @@ def force_utf8_attributes_encoding(model)
118118
model['attributes'].each do |name, value|
119119
if value.respond_to?(:force_encoding)
120120
begin
121-
model['attributes'][name] = value.force_encoding('utf-8')
121+
encoded_value = value.force_encoding('utf-8')
122+
encoded_value = value.encode!('utf-8', invalid: :replace, undef: :replace, replace: '?')
123+
model['attributes'][name] = encoded_value.valid_encoding? ? encoded_value : nil
122124
rescue
123125
# NOTICE: Enums are frozen Strings
124126
end

0 commit comments

Comments
 (0)