From 91c3b4f396f034ba7fa367b1fd2ed09c068a1970 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Tue, 20 Jun 2017 16:47:27 -0300 Subject: [PATCH] Guillermo - Issue #20 --- server/libs/FileUploader.php | 2 +- tests/system/file-upload-download.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/libs/FileUploader.php b/server/libs/FileUploader.php index 8e01e089..d078927e 100755 --- a/server/libs/FileUploader.php +++ b/server/libs/FileUploader.php @@ -33,7 +33,7 @@ class FileUploader extends FileManager { private function setNewName($fileName) { $newName = $fileName; $newName = strtolower($newName); - $newName = preg_replace('/\s+/', '_', $newName); + $newName = preg_replace('/[^a-zA-Z0-9\d\.\-]/', '_', $newName); if ($this->linearCongruentialGenerator instanceof LinearCongruentialGenerator) { $newName = $this->linearCongruentialGenerator->generate($this->linearCongruentialGeneratorOffset) . '_' . $newName; diff --git a/tests/system/file-upload-download.rb b/tests/system/file-upload-download.rb index 9319422c..ac407196 100644 --- a/tests/system/file-upload-download.rb +++ b/tests/system/file-upload-download.rb @@ -3,7 +3,7 @@ describe 'File Upload and Download' do Scripts.login('creator@os4.com', 'creator') it 'should upload file when creating ticket' do - file = File.new('../server/files/upload.txt', 'w+') + file = File.new('../server/files/upload(3).txt', 'w+') file.puts('file content') file.close @@ -14,13 +14,13 @@ describe 'File Upload and Download' do 'content' => 'this is a ticket that contains a file', 'language' => 'en', 'departmentId' => 1, - 'file' => File.open( "../server/files/upload.txt") + 'file' => File.open( "../server/files/upload(3).txt") }) (result['status']).should.equal('success') ticket = $database.getLastRow('ticket') - (ticket['file'].include? 'upload.txt').should.equal(true) + (ticket['file'].include? 'upload_3_.txt').should.equal(true) (File.exist? ('../server/files/' + ticket['file'])).should.equal(true) end