Merged in bugfix/PMC-557-B (pull request #6827)

PMC-557

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2019-03-28 19:12:21 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 51 additions and 6 deletions

View File

@@ -3225,7 +3225,6 @@ class G
'/Ö/' => 'Oe',
'/ß/' => 'ss',
'/[\.|\,|\+|\"|\:|\;|\-|\\|\/]/' => " ",
'/\\\\/' => $replacement,
'/\\s+/' => $replacement);
$map = array_merge($default, $map);

View File

@@ -77,8 +77,8 @@ if (defined('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION') && DISABLE_DOWNLOAD
}
}
$info = pathinfo(G::inflect($oAppDocument->getAppDocFilename()));
$docFileName = fixContentDispositionFilename($oAppDocument->getAppDocFilename());
$info = pathinfo($docFileName);
if (!isset($_GET['ext'])) {
$ext = $info['extension'];
} else {
@@ -133,7 +133,7 @@ if (!$sw_file_exists) {
$res['message'] = $info['basename'] . $ver . '.' . $ext;
print G::json_encode($res);
} else {
$nameFile = G::inflect($info['basename'] . $ver) . '.' . $ext;
$nameFile = $info['basename'] . $ver . '.' . $ext;
$licensedFeatures = PMLicensedFeatures::getSingleton();
$downloadStatus = false;
/*----------------------------------********---------------------------------*/

View File

@@ -444,7 +444,8 @@ try {
}
//END: If there is a Break Step registered from Plugin
$sFilenameOriginal = $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
$outDocFile = replacePrefixes($aOD['OUT_DOC_FILENAME']);
$sFilenameOriginal = $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($outDocFile, $Fields['APP_DATA']));
//Get the Custom Folder ID (create if necessary)
$oFolder = new AppFolder();

View File

@@ -451,7 +451,8 @@ class OutputDocument
$oOutputDocument = new \OutputDocument();
$aOD = $oOutputDocument->load($outputID);
$Fields = $oCase->loadCase($sApplication);
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
$outDocFile = replacePrefixes($aOD['OUT_DOC_FILENAME']);
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($outDocFile, $Fields['APP_DATA']));
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
//Get the Custom Folder ID (create if necessary)

View File

@@ -431,6 +431,50 @@ function arrayDiffRecursive(array $array1, array $array2)
return $difference;
}
/**
* Replace all supported variables prefixes to the prefix sent
*
* @param string $outDocFilename
* @param string $prefix
*
* @return string
*
* @see cases_Step.php
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::addCasesOutputDocument()
* @link https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
*/
function replacePrefixes($outDocFilename, $prefix = '@=')
{
$outDocFile = str_replace(['@@', '@#', '@=', '@%', '@?', '@$', '@&', '@Q', '@q', '@!'], $prefix, $outDocFilename);
return $outDocFile;
}
/**
* Encoding header filename used in Content-Disposition
*
* @param string $fileName
* @param string $replacement
*
* @return string
*
* @see cases_Step.php
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::addCasesOutputDocument()
*/
function fixContentDispositionFilename($fileName, $replacement = '_')
{
//(double quote) has to be removed
//(forward slash) has to replaced by underscore
//(backslash) has to replaced by underscore
$default = [
'/[\"]/' => '',
'/[\\|\/]/' => $replacement,
'/\\\\/' => $replacement
];
return preg_replace(array_keys($default), array_values($default), $fileName);
}
/**
* Get the current user CSRF token.
*