A platform for community discussion. Free, open, simple.
FIX: only allow printable characters in uploads filename
Régis Hanold1607a387a1e
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rbindex 8065d1e6f81..ea365b18b3f 100644--- a/lib/upload_creator.rb+++ b/lib/upload_creator.rb@@ -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 = optsenddiff --git a/spec/lib/upload_creator_spec.rb b/spec/lib/upload_creator_spec.rbindex bee9ffad936..614916ec4fd 100644--- a/spec/lib/upload_creator_spec.rb+++ b/spec/lib/upload_creator_spec.rb@@ -14,7 +14,7 @@ RSpec.describe UploadCreator doit 'should store the upload with the right extension' doexpect 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