Ticket #4939: 4939.patch

File 4939.patch, 3.1 KB (added by Wiktor Walc, 14 years ago)
  • _source/includes/io.js

     
    402402
    403403                isChildPath : function( childPath, parentPath )
    404404                {
    405                         if ( childPath.length > parentPath.length )
     405                        if ( childPath.length() < parentPath.length() )
    406406                                return false;
    407407
    408408                        var i = 0, max = Math.min( childPath.length(), parentPath.length() );
     
    410410                        while ( i < max && childPath.charAt( i ) == parentPath.charAt( i ) )
    411411                                i++;
    412412
    413                         return i != max;
     413                        return ( i == max );
    414414                }
    415415        };
    416416} )();
  • _source/includes/releaser.js

     
    466466                                throw "Source and target directory cannot be identical";
    467467
    468468                        if ( CKRELEASER.io.isChildPath( targetDir.getCanonicalPath(), sourceDir.getCanonicalPath() ) )
    469                                 throw "Target directory must be located outside source directory";
     469                        {
     470                                var _dir, targetDirIsIgnored = false;
     471                                for ( var i = 0 ; i < CKRELEASER.release.ignore.length ; i++ )
     472                                {
     473                                        _dir = new File( sourceDir, CKRELEASER.release.ignore[i] );
     474                                        if ( CKRELEASER.io.isChildPath( targetDir.getCanonicalPath(), _dir.getCanonicalPath() ) )
     475                                                targetDirIsIgnored = true;
     476                                }
     477                                if ( !targetDirIsIgnored )
     478                                        throw "Target directory must be located outside the source directory";
     479                        }
    470480
    471481                        if ( !releaseDir.mkdirs() )
    472482                                throw "Cannot create release directory (" + releaseDir + ")";
  • test/test.js

     
    303303                var areEqual = files.toString().replace(/\\/g, "/") == validResult.toString();
    304304                assertEquals( true, areEqual, "Comparing plugins directories (are equal?)" );
    305305        }
     306
     307        function testIO() {
     308                var releaser = new CKRELEASER.releaser();
     309                // isChildPath(child, parent)
     310                var result = [
     311                        CKRELEASER.io.isChildPath( new java.lang.String("C:/path/to/directory"), new java.lang.String("C:/path") ),
     312                        CKRELEASER.io.isChildPath( new java.lang.String("C:/path"), new java.lang.String("C:/path/to/directory") ),
     313                        CKRELEASER.io.isChildPath( new java.lang.String("C:/foo"), new java.lang.String("C:/bar") ),
     314                        CKRELEASER.io.isChildPath( new java.lang.String("C:/foo/bar"), new java.lang.String("C:/baz") ),
     315                        CKRELEASER.io.isChildPath( new java.lang.String("D:\\htdocs\\ckeditor_trunk\\_dev\\releaser\\release"), new java.lang.String("D:\\htdocs\\ckeditor_trunk") ),
     316                        CKRELEASER.io.isChildPath( new java.lang.String("C:/foo"), new java.lang.String("C:/bar/baz") )
     317                ];
     318                assertEquals( [true, false, false, false, true, false].toString(), result.toString(), "Checking isChildPath()" );
     319        }
     320
    306321        prepareTempDirs();
    307322        testDirectives();
    308323        testSkins();
     
    310325        testBom();
    311326        testLineEndings();
    312327        testCopyFiles();
     328        testIO();
    313329
    314330        print( '' );
    315331        print( 'Finished: ' + passCount + ' passed / ' + failCount + ' failed' );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy