mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +08:00
FIX: only allow printable characters in uploads filename
This commit is contained in:
parent
e94b5b4d78
commit
d1607a387a
|
@ -22,8 +22,8 @@ class UploadCreator
|
|||
# - for_export (boolean)
|
||||
def initialize(file, filename, opts = {})
|
||||
@file = file
|
||||
@filename = filename || ''
|
||||
@upload = Upload.new(original_filename: filename, filesize: 0)
|
||||
@filename = (filename || "").gsub(/[^[:print:]]/, "")
|
||||
@upload = Upload.new(original_filename: @filename, filesize: 0)
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe UploadCreator do
|
|||
|
||||
it 'should store the upload with the right extension' do
|
||||
expect do
|
||||
UploadCreator.new(file, filename).create_for(user.id)
|
||||
UploadCreator.new(file, "utf-8\n.txt").create_for(user.id)
|
||||
end.to change { Upload.count }.by(1)
|
||||
|
||||
upload = Upload.last
|
||||
|
|
Loading…
Reference in New Issue
Block a user