Ticket #1919: 1919_pre.patch

File 1919_pre.patch, 7.0 KB (added by Martin Kou, 16 years ago)

Preliminary patch with all JavaScript, HTML, Perl, Python and PHP script fixed.

  • editor/filemanager/browser/default/browser.html

     
    2727                <link href="browser.css" type="text/css" rel="stylesheet">
    2828                <script type="text/javascript" src="js/fckxml.js"></script>
    2929                <script language="javascript">
     30// Automatically detect the correct document.domain (#1919).
     31(function()
     32{
     33        var d = document.domain ;
    3034
     35        while ( true )
     36        {
     37                // Test if we can access a parent property.
     38                try
     39                {
     40                        var test = window.opener.document.domain ;
     41                        break ;
     42                }
     43                catch( e ) {}
     44
     45                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     46                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     47
     48                if ( d.length == 0 )
     49                        break ;         // It was not able to detect the domain.
     50
     51                try
     52                {
     53                        document.domain = d ;
     54                }
     55                catch (e)
     56                {
     57                        break ;
     58                }
     59        }
     60})() ;
     61
    3162function GetUrlParam( paramName )
    3263{
    3364        var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
  • editor/filemanager/browser/default/frmactualfolder.html

     
    2525        <head>
    2626                <link href="browser.css" type="text/css" rel="stylesheet">
    2727                <script type="text/javascript">
     28// Automatically detect the correct document.domain (#1919).
     29(function()
     30{
     31        var d = document.domain ;
    2832
     33        while ( true )
     34        {
     35                // Test if we can access a parent property.
     36                try
     37                {
     38                        var test = window.top.opener.document.domain ;
     39                        break ;
     40                }
     41                catch( e ) {}
     42
     43                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     44                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     45
     46                if ( d.length == 0 )
     47                        break ;         // It was not able to detect the domain.
     48
     49                try
     50                {
     51                        document.domain = d ;
     52                }
     53                catch (e)
     54                {
     55                        break ;
     56                }
     57        }
     58})() ;
     59
    2960function OnResize()
    3061{
    3162        divName.style.width = "1px" ;
  • editor/filemanager/browser/default/js/common.js

     
    2222 * File Browser dialog window.
    2323 */
    2424
     25// Automatically detect the correct document.domain (#1919).
     26(function()
     27{
     28        var d = document.domain ;
     29
     30        while ( true )
     31        {
     32                // Test if we can access a parent property.
     33                try
     34                {
     35                        var test = window.top.opener.document.domain ;
     36                        break ;
     37                }
     38                catch( e ) {}
     39
     40                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     41                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     42
     43                if ( d.length == 0 )
     44                        break ;         // It was not able to detect the domain.
     45
     46                try
     47                {
     48                        document.domain = d ;
     49                }
     50                catch (e)
     51                {
     52                        break ;
     53                }
     54        }
     55})() ;
     56
    2557function AddSelectOption( selectElement, optionText, optionValue )
    2658{
    2759        var oOption = document.createElement("OPTION") ;
  • editor/filemanager/connectors/perl/commands.pl

     
    169169
    170170        local($sErrorNumber, $sFileUrl, $sFileName, $customMsg) = @_;
    171171
    172         print "Content-type: text/html\n\n";
    173         print '<script type="text/javascript">';
     172        print <<EOF
     173Content-type: text/html
     174
     175<script type="text/javascript">
     176// Automatically detect the correct document.domain (#1919).
     177(function()
     178{
     179        var d = document.domain ;
     180
     181        while ( true )
     182        {
     183                // Test if we can access a parent property.
     184                try
     185                {
     186                        var test = window.top.opener.document.domain ;
     187                        break ;
     188                }
     189                catch( e ) {}
     190
     191                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     192                d = d.replace( /.*?(?:\\.|\$)/, '' ) ;
     193
     194                if ( d.length == 0 )
     195                        break ;         // It was not able to detect the domain.
     196
     197                try
     198                {
     199                        document.domain = d ;
     200                }
     201                catch (e)
     202                {
     203                        break ;
     204                }
     205        }
     206})() ;
     207
     208EOF
    174209        print 'window.parent.OnUploadCompleted(' . $sErrorNumber . ',"' . JS_cnv($sFileUrl) . '","' . JS_cnv($sFileName) . '","' . JS_cnv($customMsg) . '") ;';
    175210        print '</script>';
    176211        exit ;
  • editor/filemanager/connectors/php/io.php

     
    277277// This is the function that sends the results of the uploading process.
    278278function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
    279279{
    280         echo '<script type="text/javascript">' ;
     280        echo <<<EOF
     281<script type="text/javascript">
     282(function()
     283{
     284        var d = document.domain ;
     285
     286        while ( true )
     287        {
     288                // Test if we can access a parent property.
     289                try
     290                {
     291                        var test = window.top.opener.document.domain ;
     292                        break ;
     293                }
     294                catch( e ) {}
     295
     296                // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     297                d = d.replace( /.*?(?:\.|$)/, '' ) ;
     298
     299                if ( d.length == 0 )
     300                        break ;         // It was not able to detect the domain.
     301
     302                try
     303                {
     304                        document.domain = d ;
     305                }
     306                catch (e)
     307                {
     308                        break ;
     309                }
     310        }
     311})() ;
     312
     313EOF;
    281314        $rpl = array( '\\' => '\\\\', '"' => '\\"' ) ;
    282315        echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '") ;' ;
    283316        echo '</script>' ;
  • editor/filemanager/connectors/py/fckoutput.py

     
    102102                self.setHttpHeaders("text/html")
    103103                "This is the function that sends the results of the uploading process"
    104104                return """<script type="text/javascript">
     105                        (function()
     106                        {
     107                                var d = document.domain ;
     108
     109                                while ( true )
     110                                {
     111                                        // Test if we can access a parent property.
     112                                        try
     113                                        {
     114                                                var test = window.top.opener.document.domain ;
     115                                                break ;
     116                                        }
     117                                        catch( e ) {}
     118
     119                                        // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
     120                                        d = d.replace( /.*?(?:\.|$)/, '' ) ;
     121
     122                                        if ( d.length == 0 )
     123                                                break ;         // It was not able to detect the domain.
     124
     125                                        try
     126                                        {
     127                                                document.domain = d ;
     128                                        }
     129                                        catch (e)
     130                                        {
     131                                                break ;
     132                                        }
     133                                }
     134                        })() ;
     135
    105136                        window.parent.OnUploadCompleted(%(errorNumber)s,"%(fileUrl)s","%(fileName)s","%(customMsg)s");
    106137                        </script>""" % {
    107138                        'errorNumber': errorNo,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy