attempted fix for weird encoding problem

This commit is contained in:
Kyle Drake 2015-02-21 09:00:17 -08:00
parent 1f01baf664
commit cb1bb24d86

View file

@ -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
end