public function FilebrowserValidator::matchPath in Filebrowser 3.x
Same name and namespace in other branches
- 8.2 src/Services/FilebrowserValidator.php \Drupal\filebrowser\Services\FilebrowserValidator::matchPath()
Helper function to match a pattern on the path
Parameters
string $path to process:
array $patterns to search (separated by cr):
Return value
TRUE if at least one pattern is found
2 calls to FilebrowserValidator::matchPath()
- FilebrowserValidator::blackListed in src/
Services/ FilebrowserValidator.php - FilebrowserValidator::whiteListed in src/
Services/ FilebrowserValidator.php
File
- src/
Services/ FilebrowserValidator.php, line 22
Class
Namespace
Drupal\filebrowser\ServicesCode
public function matchPath($path, $patterns) {
static $regexps = NULL;
//var_dump($path);
if (!isset($regexps[$patterns])) {
$regexps[$patterns] = '/^(' . preg_replace([
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
], [
'|',
'.*',
], preg_quote($patterns, '/')) . ')$/i';
}
$result = preg_match($regexps[$patterns], $this
->safeBaseName($path)) == 1;
return $result;
}