mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Media: Replace consecutive periods in sanitize_file_name().
On some servers, consecutive periods in a filename can cause a 403 Forbidden response. This changeset replaces consecutive periods with a single period, and adds related unit tests. Props ArtZ91, costdev, SergeyBiryukov, arthurshlain, mukesh27. Fixes #57242. git-svn-id: https://develop.svn.wordpress.org/trunk@55209 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2047,6 +2047,7 @@ function sanitize_file_name( $filename ) {
|
||||
|
||||
$filename = str_replace( $special_chars, '', $filename );
|
||||
$filename = str_replace( array( '%20', '+' ), '-', $filename );
|
||||
$filename = preg_replace( '/\.{2,}/', '.', $filename );
|
||||
$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
|
||||
$filename = trim( $filename, '.-_' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user