Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

is_safe_basename()

Description

Validation helper function to determine if a path base name is unsafe (e.g OS command injection).
Very strict, limited to specific characters only. Should only be used for filenames originating in ResourceSpace.

Parameters

ColumnTypeDefaultDescription
$val: string pathinfo$val
$file_name
'_'
* PATHINFO_EXTENSION; } /**
to up
$depth: int

Location

include/file_functions.php lines 441 to 447

Definition

 
function is_safe_basename(string $val): bool
{
    
$file_name pathinfo($valPATHINFO_FILENAME);
    return
        
safe_file_name($file_name) === str_replace(' ''_'$file_name)
        && !
is_banned_extension(pathinfo($valPATHINFO_EXTENSION));
}

This article was last updated 8th August 2024 12:05 Europe/London time based on the source file dated 7th August 2024 16:55 Europe/London time.