mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 06:31:42 +00:00
normalizar todos los nombres de archivos subidos
This commit is contained in:
parent
30bc14d83e
commit
4d6a26d671
1 changed files with 21 additions and 0 deletions
21
app/lib/action_dispatch/http/uploaded_file_decorator.rb
Normal file
21
app/lib/action_dispatch/http/uploaded_file_decorator.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActionDispatch
|
||||
module Http
|
||||
# Normaliza los nombres de archivo para que se propaguen
|
||||
# correctamente a través de todo el stack.
|
||||
module UploadedFileDecorator
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Devolver el nombre de archivo con caracteres unicode
|
||||
# normalizados
|
||||
def original_filename
|
||||
@original_filename.unicode_normalize(:nfkc)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActionDispatch::Http::UploadedFile.include ActionDispatch::Http::UploadedFileDecorator
|
Loading…
Reference in a new issue