From cd5ee6005faf704cb1276dafba50b07ef16e7065 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 May 2023 14:29:40 +0200 Subject: [PATCH] Fix to show path file without will path (security) --- htdocs/core/lib/files.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e555e50b4db..4240cd0ec45 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3229,6 +3229,17 @@ function dol_readcachefile($directory, $filename) return $object; } +/** + * Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string. + * + * @param string $pathfile Full path of a file + * @return string Path of file relative to DOL_DATA_ROOT + */ +function dirbasename($pathfile) +{ + return preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'\//', '', $pathfile); +} + /** * Function to get list of updated or modified files.