WordPress.org

Make WordPress Core

Ticket #18543: wp_mkdir_p.2.diff

File wp_mkdir_p.2.diff, 895 bytes (added by adambackstrom, 3 years ago)

Prevent wp_mkdir_p from stripping // after the URL scheme

  • wp-includes/functions.php

     
    20762076 * @return bool Whether the path was created. True if path already exists. 
    20772077 */ 
    20782078function wp_mkdir_p( $target ) { 
     2079        $wrapper = null; 
     2080 
     2081        // strip the protocol  
     2082        if( wp_is_stream($target) ) { 
     2083                list( $wrapper, $target ) = explode( '://', $target, 2 ); 
     2084        } 
     2085 
    20792086        // from php.net/mkdir user contributed notes 
    20802087        $target = str_replace( '//', '/', $target ); 
    20812088 
     2089        // put the wrapper back on the target 
     2090        if( $wrapper !== null ) { 
     2091                $target = $wrapper . '://' . $target; 
     2092        } 
     2093 
    20822094        // safe mode fails with a trailing slash under certain PHP versions. 
    20832095        $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. 
    20842096        if ( empty($target) )