This commit is contained in:
Paula Quispe
2019-03-28 13:00:34 -04:00
parent fcd252dfb2
commit 2929e8ac3e
5 changed files with 51 additions and 6 deletions

View File

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

View File

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

View File

@@ -444,7 +444,8 @@ try {
} }
//END: If there is a Break Step registered from Plugin //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) //Get the Custom Folder ID (create if necessary)
$oFolder = new AppFolder(); $oFolder = new AppFolder();

View File

@@ -451,7 +451,8 @@ class OutputDocument
$oOutputDocument = new \OutputDocument(); $oOutputDocument = new \OutputDocument();
$aOD = $oOutputDocument->load($outputID); $aOD = $oOutputDocument->load($outputID);
$Fields = $oCase->loadCase($sApplication); $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 . "AppFolder.php");
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.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) //Get the Custom Folder ID (create if necessary)

View File

@@ -431,6 +431,50 @@ function arrayDiffRecursive(array $array1, array $array2)
return $difference; 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. * Get the current user CSRF token.
* *