diff --git a/app_helpers.rb b/app_helpers.rb index 2a741a41..0723f111 100644 --- a/app_helpers.rb +++ b/app_helpers.rb @@ -59,7 +59,10 @@ def encoding_fix(file) begin Rack::Utils.escape_html file rescue ArgumentError => e - return Rack::Utils.escape_html(file.force_encoding('BINARY')) if e.message =~ /invalid byte sequence in UTF-8/ + if e.message =~ /invalid byte sequence in UTF-8/ || + e.message =~ /incompatible character encodings/ + return Rack::Utils.escape_html(file.force_encoding('BINARY')) + end fail end end @@ -72,4 +75,4 @@ def send_confirmation_email(site=current_site) subject: "[Neocities] Confirm your email address", body: Tilt.new('./views/templates/email_confirm.erb', pretty: true).render(self, site: site) }) -end \ No newline at end of file +end