mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-19 10:24:50 +02:00
Use str_contains and similar instead of strpos
This commit is contained in:
parent
508de10191
commit
1dbf36b86b
16 changed files with 18 additions and 19 deletions
|
@ -134,7 +134,7 @@ class AttachmentPathResolver
|
|||
$count = 0;
|
||||
|
||||
//When path is a footprint we have to first run the string through our lecagy german mapping functions
|
||||
if (strpos($placeholder_path, '%FOOTPRINTS%') !== false) {
|
||||
if (str_contains($placeholder_path, '%FOOTPRINTS%')) {
|
||||
$placeholder_path = $this->convertOldFootprintPath($placeholder_path);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ class AttachmentPathResolver
|
|||
}
|
||||
|
||||
//Path is invalid if path is directory traversal
|
||||
if (false !== strpos($placeholder_path, '..')) {
|
||||
if (str_contains($placeholder_path, '..')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class AttachmentURLGenerator
|
|||
}
|
||||
|
||||
//Our absolute path must begin with public path, or we can not use it for asset pathes.
|
||||
if (0 !== strpos($absolute_path, $public_path)) {
|
||||
if (!str_starts_with($absolute_path, $public_path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ class FileTypeFilterTools
|
|||
}
|
||||
|
||||
//Convert *.jpg to .jpg
|
||||
if (0 === strpos($element, '*.')) {
|
||||
if (str_starts_with($element, '*.')) {
|
||||
$element = str_replace('*.', '.', $element);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ class FileTypeFilterTools
|
|||
$element = 'video/*';
|
||||
} elseif ('audio' === $element || 'audio/' === $element) {
|
||||
$element = 'audio/*';
|
||||
} elseif (!preg_match('#^[-\w.]+/[-\w.*]+#', $element) && 0 !== strpos($element, '.')) {
|
||||
} elseif (!preg_match('#^[-\w.]+/[-\w.*]+#', $element) && !str_starts_with($element, '.')) {
|
||||
//Convert jpg to .jpg
|
||||
$element = '.'.$element;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class FileTypeFilterTools
|
|||
|
||||
foreach ($elements as $element) {
|
||||
$element = trim($element);
|
||||
if (0 === strpos($element, '.')) {
|
||||
if (str_starts_with($element, '.')) {
|
||||
//We found an explicit specified file extension -> add it to list
|
||||
$extensions[] = substr($element, 1);
|
||||
} elseif ('image/*' === $element) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue