Skip to content

Commit c89fa99

Browse files
committed
minor #23766 Consistently use 7 chars of sha256 for hash-based id generation (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- Consistently use 7 chars of sha256 for hash-based id generation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This prevents generating over long service ids, and for filesystem-related changes, makes the Windows 258 chars limit farther. Commits ------- bc22cdd034 Consistently use 7 chars of sha256 for hash-based id generation
2 parents a6302b2 + ed23ba2 commit c89fa99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Field/FileFormField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function setValue($value)
5959
$name = $info['basename'];
6060

6161
// copy to a tmp location
62-
$tmp = sys_get_temp_dir().'/'.sha1(uniqid(mt_rand(), true));
62+
$tmp = sys_get_temp_dir().'/'.strtr(substr(base64_encode(hash('sha256', uniqid(mt_rand(), true), true)), 0, 7), '/', '_');
6363
if (array_key_exists('extension', $info)) {
6464
$tmp .= '.'.$info['extension'];
6565
}

0 commit comments

Comments
 (0)