Commit 529fb93a authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'F7223allow-inFilenames' into 'master'

F7223allow in filenames

See merge request !114
parents 75e02951 6a4dd684
Pipeline #1119 passed with stage
in 1 minute and 32 seconds
......@@ -327,6 +327,14 @@ class Save {
/**
* Process all Upload Formelements for the given $recordId. After processing &$formValues will be updated with the
* final filenames.
*
* Constellation: # FILE OLD FILE NEW FILESIZE
* 1 none none
* 2 none new
* 3 exist no change
* 4 delete none
* 5 delete new
*
* @param $recordId
* @throws CodeException
* @throws DbException
......@@ -339,6 +347,7 @@ class Save {
$sip = new Sip(false);
$newValues = array();
$vars=array();
$formValues = $this->store->getStore(STORE_FORM);
$primaryRecord = $this->store->getStore(STORE_RECORD); // necessary to check if the current formElement exist as a column of the primary table.
......@@ -362,10 +371,27 @@ class Save {
$column = $formElement[FE_NAME];
$pathFileName = $this->doUpload($formElement, $formValues[$column], $sip, $modeUpload);
$pathFileNameTmp = empty($pathFileName) ? $primaryRecord[$column] : $pathFileName;
if($modeUpload==UPLOAD_MODE_DELETEOLD && $pathFileName==''){
$pathFileNameTmp=''; // see '4'
} else {
if (empty($pathFileName)) {
$pathFileNameTmp = $primaryRecord[$column]; // see '3'
} else {
$pathFileNameTmp = $pathFileName; // see '1,2,5'
}
}
// Get latest file information
$vars = HelperFile::getFileStat($pathFileNameTmp);
$this->store->appendToStore($vars, STORE_VAR);
if($pathFileNameTmp=='') {
// No new upload and no existing: take care to remove previous upload file statistics.
$this->store->unsetVar(VAR_FILE_MIME_TYPE, STORE_VAR);
$this->store->unsetVar(VAR_FILE_SIZE, STORE_VAR);
} else {
$vars = HelperFile::getFileStat($pathFileNameTmp);
$this->store->appendToStore($vars, STORE_VAR);
}
// If given: fire a sqlBefore query
$this->evaluate->parse($formElement[FE_SQL_BEFORE]);
......
......@@ -171,7 +171,7 @@ class Sanitize {
public static function safeFilename($filename, $flagBaseName = false, $allowSlash = false) {
// Disallow 'none alphanumeric'. Allow dot or underscore and conditionally '/'.
$pattern = ($allowSlash) ? '([^[:alnum:]._/])' : '([^[:alnum:]._])';
$pattern = ($allowSlash) ? '([^[:alnum:]._\-/])' : '([^[:alnum:]._\-])';
$search = array(
// Definition of German Umlauts START
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment