Skip to content

Commit

Permalink
Evarisk#3425 [DU] fix: sanitize zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed Oct 17, 2023
1 parent ef4ee2d commit c798e93
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@

$date = dol_print_date(dol_now(), 'dayxcard');
$nameSociety = str_replace(' ', '_', $conf->global->MAIN_INFO_SOCIETE_NOM);
$nameSociety = preg_replace('/\./', '_', $conf->global->MAIN_INFO_SOCIETE_NOM);
$nameSociety = preg_replace('/\./', '_', $nameSociety);
$nameSociety = dol_sanitizeFileName($nameSociety);

$pathToZip = DOL_DATA_ROOT . $entity . '/digiriskdolibarr/riskassessmentdocument/' . $date . '_'. $document->ref . '_' . $nameSociety;
dol_mkdir($pathToZip);
Expand Down Expand Up @@ -474,10 +475,8 @@
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_dir_list($diroutput, 'files', 0, '', [], 'date', 'SORT_DESC');
$lastRef = pathinfo($fileparams[0]['name']);
$lastRefSanitized = dol_sanitizeFileName($lastRef['filename']);
$lastRefSanitized = str_replace(' ', '_', $lastRefSanitized);
foreach ($fileparams as $fileparam) {
preg_match('/' . $lastRef['filename'] . '/', $fileparam['name']) || preg_match('/' . $lastRefSanitized . '/', $fileparam['name']) ? $filevalue[] = $fileparam['fullname'] : 0;
preg_match('/' . $lastRef['filename'] . '/', $fileparam['name']) ? $filevalue[] = $fileparam['fullname'] : 0;
}
}

Expand Down

0 comments on commit c798e93

Please sign in to comment.