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/functions.php

    r53887 r53934  
    20842084 *
    20852085 * @since 2.5.0
     2086 * @since 6.1.0 Allows normalized Windows paths (forward slashes).
    20862087 *
    20872088 * @param string $path File path.
     
    21112112    // Windows allows absolute paths like this.
    21122113    if ( preg_match( '#^[a-zA-Z]:\\\\#', $path ) ) {
     2114        return true;
     2115    }
     2116
     2117    // Normalized Windows paths for local filesystem and network shares (forward slashes).
     2118    if ( preg_match( '#(^[a-zA-Z]+:/|^//[\w!@\#\$%\^\(\)\-\'{}\.~]{1,15})#', $path ) ) {
    21132119        return true;
    21142120    }
Note: See TracChangeset for help on using the changeset viewer.