Merged in bugfix/PMC-1297 (pull request #7096)

PMC-1297

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Andrea Adamczyk
2019-10-10 16:27:01 +00:00
committed by Paula Quispe
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Util\Helpers;
use Tests\TestCase;
class FixContentDispositionFilenameTest extends TestCase
{
/**
* It tests that the special characters are being replaced
* @test
*/
public function it_should_test_the_special_characters_located_in_a_filename()
{
//The file name send to the function
$fileName = "text\"text ?text/text";
//Calling the fixContentDispositionFilename() function
$res = fixContentDispositionFilename($fileName);
//Assert the special characters where replaced with the correct values
$this->assertEquals('texttext _text_text', $res);
}
}

View File

@@ -488,10 +488,12 @@ function changeAbbreviationOfDirectives($size)
function fixContentDispositionFilename($fileName, $replacement = '_')
{
//(double quote) has to be removed
//(question mark) has to be replaced by underscore due to the issue in google chrome
//(forward slash) has to replaced by underscore
//(backslash) has to replaced by underscore
$default = [
'/[\"]/' => '',
'/[\?]/' => $replacement,
'/[\\|\/]/' => $replacement,
'/\\\\/' => $replacement
];