Changeset 1797

Show
Ignore:
Timestamp:
2008-03-25 14:01:57 (2 years ago)
Author:
wwalc
Message:

Fix for #1944, backslash is disallowed in currentfolder parameter: ColdFusion, Perl, PHP, Python

Location:
FCKeditor/trunk/editor/filemanager/connectors
Files:
12 modified

Legend:

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

    r1791 r1797  
    173173 
    174174        ' Check for invalid folder paths (..) 
    175         If ( InStr( 1, sCurrentFolder, ".." ) <> 0 ) Then 
     175        If ( InStr( 1, sCurrentFolder, ".." ) <> 0 OR InStr( 1, sCurrentFolder, "\" ) <> 0) Then 
    176176                SendError 102, "" 
    177177        End If 
  • FCKeditor/trunk/editor/filemanager/connectors/asp/upload.asp

    r1565 r1797  
    3333<% 
    3434 
     35Sub SendError( number, text ) 
     36        SendUploadResults number, "", "", text 
     37End Sub 
     38 
    3539' Check if this uploader has been enabled. 
    3640If ( ConfigIsEnabled = False ) Then 
  • FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_connector.cfm

    r1565 r1797  
    130130        <cfset xmlContent = "<Error number=""1"" text=""This connector is disabled. Please check the 'editor/filemanager/connectors/cfm/config.cfm' file"" />"> 
    131131 
    132 <cfelseif find("..",url.currentFolder)> 
     132<cfelseif find("..",url.currentFolder) or find("\",url.currentFolder)> 
    133133 
    134134        <cfset xmlContent = "<Error number=""102"" />"> 
  • FCKeditor/trunk/editor/filemanager/connectors/cfm/cf5_upload.cfm

    r1791 r1797  
    100100</cfif> 
    101101 
    102 <cfif find( "..", url.currentFolder)> 
     102<cfif find( "..", url.currentFolder) or find( "\", url.currentFolder)> 
    103103        <cfset SendUploadResults(102)> 
    104104        <cfabort> 
  • FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_io.cfm

    r1791 r1797  
    175175</cffunction> 
    176176 
    177 <cffunction name="GetCurrentFolder" returntype="String" output="false"> 
     177<cffunction name="GetCurrentFolder" returntype="String" output="true"> 
    178178        <cfset var sCurrentFolder = "/"> 
    179179 
     
    194194        <cfset sCurrentFolder = rereplace( sCurrentFolder, "//+", "/", "all" )> 
    195195 
    196         <cfif find( "..", sCurrentFolder)> 
     196        <cfif find( "..", sCurrentFolder) or find( "\", sCurrentFolder) > 
    197197                <cfset SendError( 102, "" )> 
    198198        </cfif> 
  • FCKeditor/trunk/editor/filemanager/connectors/cfm/cf_upload.cfm

    r1565 r1797  
    3434<cfinclude template="cf_commands.cfm"> 
    3535 
     36<cffunction name="SendError" returntype="void" output="true"> 
     37        <cfargument name="number" required="true" type="Numeric"> 
     38        <cfargument name="text" required="true"> 
     39        <cfreturn SendUploadResults( "#ARGUMENTS.number#", "", "", "ARGUMENTS.text" )> 
     40</cffunction> 
     41 
    3642<cfset REQUEST.Config = Config> 
    3743<cfif find( "/", getBaseTemplatePath() ) > 
  • FCKeditor/trunk/editor/filemanager/connectors/lasso/connector.lasso

    r1791 r1797  
    5656        ); 
    5757 
     58        /*..................................................................... 
     59        Custom tag sets the HTML response. 
     60        */ 
     61         
     62        define_tag( 
     63                'htmlreply', 
     64                -namespace='fck_', 
     65                -priority='replace', 
     66                -required='uploadResult', 
     67                -optional='NewFilePath', 
     68                -type='string', 
     69                -description='Sets the HTML response for the FCKEditor File Upload feature.' 
     70        ); 
     71                $__html_reply__ = '\ 
     72<script type="text/javascript"> 
     73(function() 
     74{ 
     75        var d = document.domain ; 
     76 
     77        while ( true ) 
     78        { 
     79                // Test if we can access a parent property. 
     80                try 
     81                { 
     82                        var test = window.top.opener.document.domain ; 
     83                        break ; 
     84                } 
     85                catch( e ) {} 
     86 
     87                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 
     88                d = d.replace( /.*?(?:\\.|$)/, "" ) ; 
     89 
     90                if ( d.length == 0 ) 
     91                        break ;         // It was not able to detect the domain. 
     92 
     93                try 
     94                { 
     95                        document.domain = d ; 
     96                } 
     97                catch (e) 
     98                { 
     99                        break ; 
     100                } 
     101        } 
     102})() ; 
     103'; 
     104                        if($uploadResult == '0' || $uploadResult == '201'); 
     105                        $__html_reply__ = $__html_reply__ + '\ 
     106        window.parent.OnUploadCompleted(' + $uploadResult + ',\'' + $NewFilePath + '\',\'' + $NewFilePath->split('/')->last + '\'); 
     107</script> 
     108                        '; 
     109                        else; 
     110                        $__html_reply__ = $__html_reply__ + '\ 
     111        window.parent.OnUploadCompleted(' + $uploadResult + '); 
     112</script> 
     113                        '; 
     114                        /if; 
     115        /define_tag; 
     116         
    58117 
    59118    /*..................................................................... 
     
    64123        var('currentFolderURL' = $ServerPath 
    65124                + $config->find('Subdirectories')->find(action_param('Type')) 
    66                 + action_param('CurrentFolder') 
     125                + $CurrentFolder 
    67126        ); 
    68127 
    69  
     128        if($CurrentFolder->(Find: '..') || $CurrentFolder->(Find: '\\')); 
     129                if($Command == 'FileUpload'); 
     130                        $responseType = 'html'; 
     131                        $uploadResult = '102'; 
     132                        fck_htmlreply( 
     133                                -uploadResult=$uploadResult 
     134                        ); 
     135                else; 
     136                        $errorNumber = 102; 
     137                        $commandData += '<Error number="' + $errorNumber + '" />\n'; 
     138                /if; 
     139        else; 
     140         
    70141    /*..................................................................... 
    71142    Build the appropriate response per the 'Command' parameter. Wrap the 
     
    150221                Was a file actually uploaded? 
    151222                */ 
    152                                 file_uploads->size ? $NewFile = file_uploads->get(1) | $uploadResult = '202'; 
    153  
     223                if(file_uploads->size); 
     224                        $NewFile = file_uploads->get(1); 
     225                else; 
     226                        $uploadResult = '202'; 
     227                /if; 
     228                 
    154229                                if($uploadResult == '0'); 
    155230                    /*..................................................... 
     
    195270                                                                $OrigFilePath != $NewFilePath ? $uploadResult = 201; 
    196271                                                        case; 
    197                                                                 $uploadResult = '202'; 
     272                                                                $uploadResult = file_currenterror( -errorcode); 
    198273                                                /select; 
    199274                                        /if; 
    200275                                /if; 
    201  
    202  
    203                 /*......................................................... 
    204                 Set the HTML response. 
    205                 */ 
    206                 $__html_reply__ = '\ 
    207 <script type="text/javascript"> 
    208 (function() 
    209 { 
    210         var d = document.domain ; 
    211  
    212         while ( true ) 
    213         { 
    214                 // Test if we can access a parent property. 
    215                 try 
    216                 { 
    217                         var test = window.top.opener.document.domain ; 
    218                         break ; 
    219                 } 
    220                 catch( e ) {} 
    221  
    222                 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 
    223                 d = d.replace( /.*?(?:\\.|$)/, "" ) ; 
    224  
    225                 if ( d.length == 0 ) 
    226                         break ;         // It was not able to detect the domain. 
    227  
    228                 try 
    229                 { 
    230                         document.domain = d ; 
    231                 } 
    232                 catch (e) 
    233                 { 
    234                         break ; 
    235                 } 
    236         } 
    237 })() ; 
    238 '; 
    239                                 if($uploadResult == '0' || $uploadResult == '201'); 
    240                                 $__html_reply__ = $__html_reply__ + '\ 
    241         window.parent.OnUploadCompleted(' + $uploadResult + ',\'' + $NewFilePath + '\',\'' + $NewFilePath->split('/')->last + '\'); 
    242 </script> 
    243                                 '; 
    244                                 else; 
    245                                 $__html_reply__ = $__html_reply__ + '\ 
    246         window.parent.OnUploadCompleted(' + $uploadResult + '); 
    247 </script> 
    248                                 '; 
    249                                 /if; 
     276                                fck_htmlreply( 
     277                                        -uploadResult=$uploadResult, 
     278                                        -NewFilePath=$NewFilePath 
     279                                ); 
    250280                /select; 
    251281        /inline; 
    252  
     282        /if; 
    253283 
    254284    /*..................................................................... 
     
    269299Content-Type: text/xml; charset=utf-8 
    270300[//lasso 
    271                 /header; 
    272  
    273  
    274         /*................................................................. 
    275         Set the content type encoding for Lasso. 
    276         */ 
     301/header; 
     302 
     303                /* 
     304                        Set the content type encoding for Lasso. 
     305                */ 
    277306                content_type('text/xml; charset=utf-8'); 
    278307 
    279  
    280         /*................................................................. 
    281         Wrap the response as XML and output. 
    282         */ 
     308                /* 
     309                        Wrap the response as XML and output. 
     310                */ 
    283311                $__html_reply__ = '\ 
    284312<?xml version="1.0" encoding="utf-8" ?> 
    285 <Connector command="' + $Command + '" resourceType="' + $Type + '"> 
    286         <CurrentFolder path="' + $CurrentFolder + '" url="' + $currentFolderURL + '" /> 
    287 ' + $commandData + ' 
    288 </Connector> 
    289                 '; 
     313<Connector command="' + $Command + '" resourceType="' + $Type + '">'; 
     314 
     315                if($errorNumber != '102'); 
     316                        $__html_reply__ += '<CurrentFolder path="' + $CurrentFolder + '" url="' + $currentFolderURL + '" />'; 
     317                /if; 
     318 
     319                $__html_reply__ += $commandData + ' 
     320</Connector>'; 
    290321        /if; 
    291322] 
  • FCKeditor/trunk/editor/filemanager/connectors/lasso/upload.lasso

    r1565 r1797  
    5757        ); 
    5858 
    59  
    6059        /*..................................................................... 
    6160        Custom tag sets the HTML response. 
     
    7877                $__html_reply__ = '\ 
    7978<script type="text/javascript"> 
     79(function() 
     80{ 
     81        var d = document.domain ; 
     82 
     83        while ( true ) 
     84        { 
     85                // Test if we can access a parent property. 
     86                try 
     87                { 
     88                        var test = window.top.opener.document.domain ; 
     89                        break ; 
     90                } 
     91                catch( e ) {} 
     92 
     93                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 
     94                d = d.replace( /.*?(?:\\.|$)/, "" ) ; 
     95 
     96                if ( d.length == 0 ) 
     97                        break ;         // It was not able to detect the domain. 
     98 
     99                try 
     100                { 
     101                        document.domain = d ; 
     102                } 
     103                catch (e) 
     104                { 
     105                        break ; 
     106                } 
     107        } 
     108})() ; 
    80109        window.parent.OnUploadCompleted(' + #errorNumber + ',"' 
    81110                + string_replace(#fileUrl, -find='"', -replace='\\"') + '","' 
     
    86115        /define_tag; 
    87116 
     117        if($CurrentFolder->(Find: '..') || $CurrentFolder->(Find: '\\')); 
     118                $errorNumber = 102; 
     119        /if; 
    88120 
    89121        if($config->find('Enabled')); 
     
    95127                        Was a file actually uploaded? 
    96128                        */ 
    97                         file_uploads->size ? $NewFile = file_uploads->get(1) | $errorNumber = 202; 
     129                        if($errorNumber != '102'); 
     130                                file_uploads->size ? $NewFile = file_uploads->get(1) | $errorNumber = 202; 
     131                        /if; 
    98132 
    99133                        if($errorNumber == 0); 
  • FCKeditor/trunk/editor/filemanager/connectors/perl/connector.cgi

    r1565 r1797  
    102102 
    103103        # Check for invalid folder paths (..) 
    104         if ( $sCurrentFolder =~ /\.\./ ) { 
     104        if ( $sCurrentFolder =~ /(?:\.\.|\\)/ ) { 
    105105                SendError( 102, "" ) ; 
    106106        } 
  • FCKeditor/trunk/editor/filemanager/connectors/perl/upload.cgi

    r1565 r1797  
    105105 
    106106        # Check for invalid folder paths (..) 
    107         if ( $sCurrentFolder =~ /\.\./ ) { 
     107        if ( $sCurrentFolder =~ /(?:\.\.|\\)/ ) { 
    108108                SendError( 102, "" ) ; 
    109109        } 
  • FCKeditor/trunk/editor/filemanager/connectors/php/io.php

    r1791 r1797  
    241241 
    242242        // Check for invalid folder paths (..) 
    243         if ( strpos( $sCurrentFolder, '..' ) ) 
     243        if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) 
    244244                SendError( 102, '' ) ; 
    245245 
  • FCKeditor/trunk/editor/filemanager/connectors/py/fckutil.py

    r1651 r1797  
    9090 
    9191        # Check for invalid folder paths (..) 
    92         if '..' in currentFolder: 
     92        if '..' in currentFolder or '\\' in currentFolder: 
    9393                return None 
    9494