Changeset 391

Show
Ignore:
Timestamp:
2007-06-26 00:10:59 (2 years ago)
Author:
fredck
Message:

Fix for SA25719.

Location:
FCKeditor/trunk/editor/filemanager
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/filemanager/browser/default/connectors/php/commands.php

    r132 r391  
    160160                $oFile = $_FILES['NewFile'] ; 
    161161 
    162                 // Map the virtual path to the local server path. 
    163                 $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; 
    164  
    165162                // Get the uploaded file name. 
    166163                $sFileName = $oFile['name'] ; 
     
    170167                        $sFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sFileName ) ; 
    171168 
    172                 $sOriginalFileName = $sFileName ; 
    173  
    174                 // Get the extension. 
    175                 $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; 
    176                 $sExtension = strtolower( $sExtension ) ; 
    177  
    178                 $arAllowed      = $Config['AllowedExtensions'][$resourceType] ; 
    179                 $arDenied       = $Config['DeniedExtensions'][$resourceType] ; 
    180  
    181                 if ( ( count($arAllowed) == 0 || in_array( $sExtension, $arAllowed ) ) && ( count($arDenied) == 0 || !in_array( $sExtension, $arDenied ) ) ) 
     169                if ( CheckFileName( $sFileName, $resourceType ) ) 
    182170                { 
     171                        // Map the virtual path to the local server path. 
     172                        $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ; 
     173                         
     174                        $sOriginalFileName = $sFileName ; 
     175 
     176                        // Get the extension. 
     177                        $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; 
     178                        $sExtension = strtolower( $sExtension ) ; 
     179 
    183180                        $iCounter = 0 ; 
    184181 
  • FCKeditor/trunk/editor/filemanager/browser/default/connectors/php/io.php

    r357 r391  
    4646        { 
    4747                if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) 
    48                 {  
     48                { 
    4949                        SendErrorNode( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ; 
    5050                        CreateXmlFooter() ; 
     
    113113        $slash = ( strpos( $sRealPath, '/' ) === false ) ? '\\' : '/' ; 
    114114        $sSelfPath = str_replace( '/', $slash, $sSelfPath ) ; 
    115          
     115 
    116116        $position = strpos( $sRealPath, $sSelfPath ) ; 
    117117 
     
    123123        return substr( $sRealPath, 0, $position ) ; 
    124124} 
     125 
     126function CheckFileName( $fileName, $resourceType ) 
     127{ 
     128        global $Config ; 
     129 
     130        // SA25719 
     131        if ( strpos( strtolower( $fileName ), '::$data' ) != false ) 
     132                return false ; 
     133 
     134        // Get the extension. 
     135        $sExtension = substr( $fileName, ( strrpos($fileName, '.') + 1 ) ) ; 
     136        $sExtension = strtolower( $sExtension ) ; 
     137 
     138        $arDenied       = $Config['DeniedExtensions'][$resourceType] ; 
     139 
     140        if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) 
     141                return false ; 
     142         
     143        $arAllowed      = $Config['AllowedExtensions'][$resourceType] ; 
     144         
     145        if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) 
     146                return false ; 
     147 
     148        return true ; 
     149} 
    125150?> 
  • FCKeditor/trunk/editor/filemanager/upload/php/upload.php

    r285 r391  
    6666    SendResults( 1, '', '', 'Invalid type specified' ) ; 
    6767 
     68// SA25719 
     69if ( strpos( strtolower( $sFileName ), '::$data' ) != false ) 
     70        SendResults( '202' ) ; 
     71 
    6872// Get the allowed and denied extensions arrays. 
    6973$arAllowed      = $Config['AllowedExtensions'][$sType] ;