Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 280582
Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/resources/ResourceManagerImpl.java (-2 / +10 lines)
Lines 364-370 Link Here
364
      StringBuffer url = new StringBuffer();
364
      StringBuffer url = new StringBuffer();
365
      url.append( URLHelper.getContextURLString() );
365
      url.append( URLHelper.getContextURLString() );
366
      url.append( "/" );
366
      url.append( "/" );
367
      url.append( versionedResourceName( newFileName, version ) );
367
      String escapedFilename = escapeFilename( newFileName );
368
      url.append( versionedResourceName( escapedFilename, version ) );
368
      result = url.toString();
369
      result = url.toString();
369
    } else {
370
    } else {
370
      StringBuffer url = new StringBuffer();
371
      StringBuffer url = new StringBuffer();
Lines 503-512 Link Here
503
    StringBuffer filename = new StringBuffer();
504
    StringBuffer filename = new StringBuffer();
504
    filename.append( webAppRoot );
505
    filename.append( webAppRoot );
505
    filename.append( File.separator );
506
    filename.append( File.separator );
506
    filename.append( versionedResourceName( name, version ) );
507
    filename.append( versionedResourceName( escapeFilename( name ), version ) );
507
    return new File( filename.toString() );
508
    return new File( filename.toString() );
508
  }
509
  }
509
  
510
  
511
  private static String escapeFilename( final String name ) {
512
    String result = name;
513
    result = name.replaceAll( "\\$", "\\$\\$" );
514
    result = result.replaceAll( ":", "\\$1" );
515
    return result;
516
  }
517
510
  private static File getTempLocation( final String name, 
518
  private static File getTempLocation( final String name, 
511
                                       final Integer version ) 
519
                                       final Integer version ) 
512
  {
520
  {
(-)src/org/eclipse/rwt/internal/resources/ResourceManagerImpl_Test.java (-1 / +20 lines)
Lines 462-470 Link Here
462
    content.close();
462
    content.close();
463
    assertNull( manager.getRegisteredContent( "not-there" ) );
463
    assertNull( manager.getRegisteredContent( "not-there" ) );
464
  }
464
  }
465
  
466
  /*
467
   * 280582: resource registration fails when using ImageDescriptor.createFromURL
468
   * https://bugs.eclipse.org/bugs/show_bug.cgi?id=280582
469
   */
470
  public void testRegisterWithInvalidFilename() throws Exception {
471
    ServiceContext context = new ServiceContext( new TestRequest(),
472
                                                 new TestResponse() );
473
    ContextProvider.setContext( context );
474
    IResourceManager manager = getManager( ResourceBase.DELIVER_FROM_DISK );
475
    InputStream inputStream = openStream( TEST_RESOURCE_2 );
476
    String name = "http://host:port/path$1";
477
    manager.register( name, inputStream );
478
    inputStream.close();
479
    String location = manager.getLocation( name );
480
    assertEquals( "http://TestCase:4711/test/http$1//host$1port/path$$1", 
481
                  location );
482
  }
465
483
466
  // ////////////////
484
  ///////////////////
467
  // helping methods
485
  // helping methods
486
  
468
  private static int[] read( final InputStream input ) throws IOException {
487
  private static int[] read( final InputStream input ) throws IOException {
469
    int[] result = null;
488
    int[] result = null;
470
    try {
489
    try {

Return to bug 280582