Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#29726 closed defect (bug) (duplicate)

Mixed Backward and Forward Slashes

Reported by: cyberwani's profile cyberwani Owned by: dd32's profile dd32
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: General Keywords: dev-feedback
Focuses: Cc:

Description

Some functions used to get the directory path giving result with mixed backward and forward slashes in Windows. List given here below:

get_template_directory():
D:\wamp\www\wp4/wp-content/themes/potenzabase
get_stylesheet_directory():
D:\wamp\www\wp4/wp-content/themes/potenzabase
get_theme_root():
D:\wamp\www\wp4/wp-content/themes
plugin_dir_path():
D:\wamp\www\wp4\wp-content\themes\potenzabase\includes\cpt/
wp_upload_dir():
Array
(
    [path] => D:\wamp\www\wp4/wp-content/uploads/2014/09
    [url] => http://192.168.22.201/wp4/wp-content/uploads/2014/09
    [subdir] => /2014/09
    [basedir] => D:\wamp\www\wp4/wp-content/uploads
    [baseurl] => http://192.168.22.201/wp4/wp-content/uploads
    [error] => 
)

This function can fix the slashes.

function fixslash($path){
        $sep = DIRECTORY_SEPARATOR;
        if( $ds == '/' ){
                $fix_sep = '\\';
        }elseif( $ds == '\\' ){
                $fix_sep = '/';
        }
        $path = str_replace($fix_sep,$sep,$path);
        return $path;
}

Change History (3)

#1 @DrewAPicture
10 years ago

  • Keywords dev-feedback added
  • Owner set to dd32
  • Status changed from new to reviewing

@dd32: Mind taking a look here?

#2 @nacin
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reviewing to closed

This is a known thing. We normalize paths with wp_normalize_path() when necessary, but mixed slashes are perfectly OK and fully functional except when doing actual path comparisons.

#3 @SergeyBiryukov
10 years ago

  • Resolution changed from invalid to duplicate

Duplicate of #28811.

Note: See TracTickets for help on using tickets.