Skip to content

Commit

Permalink
Fix issue with upload filename sanitation and files without extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Jacobs committed Jan 23, 2019
1 parent 302b309 commit 53703f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions templates/wp-content/mu-plugins/wpnp-sanitize-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

function npwp_sanitize_filename_on_upload($filename) {
$pathinfo = pathinfo($filename);
$ext = empty($pathinfo["extension"]) ? "" : $pathinfo["extension"];
$ext = empty($pathinfo["extension"]) ? "" : "." . $pathinfo["extension"];
$name = $pathinfo["filename"];

// Replace all special characters
Expand All @@ -38,5 +38,5 @@ function npwp_sanitize_filename_on_upload($filename) {
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/', '', $sanitized);
// Replace dots inside filename
$sanitized = str_replace('.', '-', $sanitized);
return strtolower($sanitized . '.' . $ext);
return strtolower($sanitized . $ext);
}

0 comments on commit 53703f1

Please sign in to comment.