WordPress.org

Make WordPress Core

Ticket #41736: 41736.patch

File 41736.patch, 972 bytes (added by subrataemfluence, 4 years ago)

Patch considers windows environment file path like c:\folder\filename.ext

  • .php

    diff --git a/functions.php b/functions-new.php
    index 771583d..433212e 100755
    old new function iis7_supports_permalinks() { 
    42384238 * return value of '2' means that the $file contains ':' after the first
    42394239 * character. A return value of '3' means that the file is not in the allowed
    42404240 * files list.
     4241 * A return value of 4 considers a special case when file is uploaded from Windows.
     4242 * In Windows environment a typical file path is like 'c:\foldername\filename.ext'
    42414243 *
    42424244 * @since 1.2.0
    42434245 *
    function validate_file( $file, $allowed_files = '' ) { 
    42564258        if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
    42574259                return 3;
    42584260
     4261        //Takes file upload from Windows environment into considertation
     4262        if(false !== strpos($file, '\\')) {
     4263                $file = substr(strrchr($file, "\\"), 1);
     4264                if (false !== strpos( $file, ':' ) )
     4265                        return 4;
     4266        }
     4267
    42594268        if (':' == substr( $file, 1, 1 ) )
    42604269                return 2;
    42614270