Make WordPress Core


Ignore:
Timestamp:
02/03/2023 12:46:18 PM (20 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r55162 r55209  
    20482048    $filename = str_replace( $special_chars, '', $filename );
    20492049    $filename = str_replace( array( '%20', '+' ), '-', $filename );
     2050    $filename = preg_replace( '/\.{2,}/', '.', $filename );
    20502051    $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
    20512052    $filename = trim( $filename, '.-_' );
Note: See TracChangeset for help on using the changeset viewer.