create-prisma-php-app 1.20.3 → 1.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -296,29 +296,33 @@ class UploadFile
|
|
|
296
296
|
|
|
297
297
|
protected function checkName(array $file): void
|
|
298
298
|
{
|
|
299
|
-
$
|
|
300
|
-
$
|
|
299
|
+
$this->newName = '';
|
|
300
|
+
$noSpaces = str_replace(' ', '_', $file['name']);
|
|
301
|
+
if ($noSpaces != $file['name']) {
|
|
302
|
+
$this->newName = $noSpaces;
|
|
303
|
+
}
|
|
304
|
+
$nameParts = pathinfo($noSpaces);
|
|
301
305
|
$extension = $nameParts['extension'] ?? '';
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
+
if (!$this->typeCheckingOn && !empty($this->suffix)) {
|
|
307
|
+
if (in_array($extension, $this->notTrusted) || empty($extension)) {
|
|
308
|
+
$this->newName = $noSpaces . $this->suffix;
|
|
309
|
+
}
|
|
306
310
|
}
|
|
307
|
-
|
|
308
|
-
// Rename duplicates if necessary
|
|
309
311
|
if ($this->renameDuplicates) {
|
|
310
|
-
$
|
|
311
|
-
$
|
|
312
|
-
$
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
$name = isset($this->newName) ? $this->newName : $file['name'];
|
|
313
|
+
$existing = scandir($this->destination);
|
|
314
|
+
if (in_array($name, $existing)) {
|
|
315
|
+
$i = 1;
|
|
316
|
+
do {
|
|
317
|
+
$this->newName = $nameParts['filename'] . '_' . $i++;
|
|
318
|
+
if (!empty($extension)) {
|
|
319
|
+
$this->newName .= ".$extension";
|
|
320
|
+
}
|
|
321
|
+
if (in_array($extension, $this->notTrusted)) {
|
|
322
|
+
$this->newName .= $this->suffix;
|
|
323
|
+
}
|
|
324
|
+
} while (in_array($this->newName, $existing));
|
|
317
325
|
}
|
|
318
|
-
|
|
319
|
-
$this->newName = $name;
|
|
320
|
-
} else {
|
|
321
|
-
$this->newName = $name;
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
|