Make WordPress Core


Ignore:
Timestamp:
08/23/2022 07:57:17 PM (2 years ago)
Author:
antpb
Message:

Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the path_is_absolute function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the get_attached_file function.
Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion.
Fixes #36308.

File:
1 edited

Legend:

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

    r53883 r53934  
    725725
    726726    // If the file is relative, prepend upload dir.
    727     if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
     727    if ( $file ) {
    728728        $uploads = wp_get_upload_dir();
     729
    729730        if ( false === $uploads['error'] ) {
    730             $file = $uploads['basedir'] . "/$file";
     731            $file = path_join( $uploads['basedir'], $file );
    731732        }
    732733    }
Note: See TracChangeset for help on using the changeset viewer.