Skip to content
Snippets Groups Projects
Commit e8d034be authored by jaapjansma's avatar jaapjansma
Browse files

Issue with export

parent 80d9cd8d
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ class CRM_DataprocessorOutputExport_Page_Download extends CRM_Core_Page {
CRM_Core_Error::statusBounce("Cannot access file");
}
if (!CRM_Utils_File::isValidFileName($fileName)) {
if (!self::isValidFileName($fileName)) {
CRM_Core_Error::statusBounce("Malformed filename");
}
......@@ -63,4 +63,23 @@ class CRM_DataprocessorOutputExport_Page_Download extends CRM_Core_Page {
);
}
/**
* Is the filename a safe and valid filename passed in from URL
*
* @param string $fileName
* @return bool
*/
protected static function isValidFileName($fileName = NULL) {
if ($fileName) {
$check = $fileName !== basename($fileName) ? FALSE : TRUE;
if ($check) {
if (substr($fileName, 0, 1) == '/' || substr($fileName, 0, 1) == '.' || substr($fileName, 0, 1) == DIRECTORY_SEPARATOR) {
$check = FALSE;
}
}
return $check;
}
return FALSE;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment