Changeset 1648

Show
Ignore:
Timestamp:
2008-02-28 10:51:35 (6 months ago)
Author:
wwalc
Message:

Fix for #1945 - sanitizing control characters in PHP.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/filemanager/connectors/php/io.php

    r1629 r1648  
    151151function GetRootPath() 
    152152{ 
    153     if (!isset($_SERVER)) { 
    154         global $_SERVER; 
    155     } 
     153        if (!isset($_SERVER)) { 
     154                global $_SERVER; 
     155        } 
    156156        $sRealPath = realpath( './' ) ; 
    157157 
     
    224224function GetCurrentFolder() 
    225225{ 
    226     if (!isset($_GET)) { 
    227         global $_GET; 
    228     } 
     226        if (!isset($_GET)) { 
     227                global $_GET; 
     228        } 
    229229        $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; 
    230230 
    231231        // Check the current folder syntax (must begin and start with a slash). 
    232         if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ; 
    233         if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ; 
     232        if ( !preg_match( '|/$|', $sCurrentFolder ) )  
     233                $sCurrentFolder .= '/' ; 
     234        if ( strpos( $sCurrentFolder, '/' ) !== 0 )  
     235                $sCurrentFolder = '/' . $sCurrentFolder ; 
    234236 
    235237        // Ensure the folder path has no double-slashes 
     
    251253 
    252254        // Remove . \ / | : ? * " < > 
    253         $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFolderName ) ; 
     255        $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ) ; 
    254256 
    255257        return $sNewFolderName ; 
     
    268270 
    269271        // Remove \ / | : ? * " < > 
    270         $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFileName ) ; 
     272        $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ; 
    271273 
    272274        return $sNewFileName ;