mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-19 18:01:30 +00:00
Use a cryptographically random suffix for attachment file names to make them harder guess
This commit is contained in:
parent
ca573c1106
commit
b4ee5c9e8e
1 changed files with 4 additions and 1 deletions
|
|
@ -137,7 +137,10 @@ class AttachmentSubmitHandler
|
||||||
$attachment->getName()
|
$attachment->getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
return $safeName.'-'.uniqid('', false).'.'.$extension;
|
// Generate a 12-character URL-safe random string, which should avoid collisions and prevent from guessing file paths.
|
||||||
|
$random = str_replace(['+', '/', '='], ['0', '1', '2'], base64_encode(random_bytes(9)));
|
||||||
|
|
||||||
|
return $safeName.'-'.$random.'.'.$extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue