Skip to content

Commit

Permalink
[4.x] Revert overzealous file extension renaming feature (#9389)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Jan 24, 2024
1 parent ecfe589 commit 5a9a762
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
13 changes: 1 addition & 12 deletions src/Assets/AssetUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function asset(Asset $asset)

protected function uploadPath(UploadedFile $file)
{
$ext = $this->getNewExtension() ?? $this->getFileExtension($file);
$ext = $this->getNewExtension() ?? $file->getClientOriginalExtension();

if (config('statamic.assets.lowercase')) {
$ext = strtolower($ext);
Expand Down Expand Up @@ -71,17 +71,6 @@ protected function getNewExtension()
return $ext;
}

private function getFileExtension(UploadedFile $file)
{
$extension = $file->getClientOriginalExtension();
$guessed = $file->guessExtension();

// Only use the guessed extension if it's different than the original.
// This allows us to maintain the casing of the original extension
// if the the "lowercase filenames" config option is disabled.
return strtolower($extension) === strtolower($guessed) ? $extension : $guessed;
}

public static function getSafeFilename($string)
{
$replacements = [
Expand Down
4 changes: 1 addition & 3 deletions src/Assets/FileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public static function container(?string $container = null)

protected function uploadPath(UploadedFile $file)
{
$filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);

return now()->timestamp.'/'.$filename.'.'.$file->guessExtension();
return now()->timestamp.'/'.$file->getClientOriginalName();
}

protected function uploadPathPrefix()
Expand Down

0 comments on commit 5a9a762

Please sign in to comment.