This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ-1019268: some additional fixes in order to avoid double encoding/d…
…ecoding pointed by neus
- Loading branch information
Showing
4 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...end/uberfire-backend-server/src/test/java/org/uberfire/backend/server/util/TestPaths.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.uberfire.backend.server.util; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class TestPaths { | ||
|
||
@Test | ||
public void test() { | ||
{ | ||
final String FILENAME = "file name.txt"; | ||
final org.uberfire.java.nio.file.Path path = org.uberfire.java.nio.file.Paths.get( "file://reponame/path/to/" ).resolve( FILENAME ); | ||
|
||
assertEquals( FILENAME, path.getFileName().toString() ); | ||
assertEquals( FILENAME, Paths.convert( path ).getFileName() ); | ||
assertEquals( FILENAME, Paths.convert( Paths.convert( path ) ).getFileName().toString() ); | ||
System.out.println( path.toUri().toString() ); | ||
System.out.println( Paths.convert( path ).toURI() ); | ||
System.out.println( Paths.convert( Paths.convert( path ) ).toUri().toString() ); | ||
} | ||
|
||
{ | ||
final String FILENAME = "file_name.txt"; | ||
final org.uberfire.java.nio.file.Path path = org.uberfire.java.nio.file.Paths.get( "file://reponame/path/to/" ).resolve( FILENAME ); | ||
|
||
assertEquals( FILENAME, path.getFileName().toString() ); | ||
assertEquals( FILENAME, Paths.convert( path ).getFileName() ); | ||
assertEquals( FILENAME, Paths.convert( Paths.convert( path ) ).getFileName().toString() ); | ||
System.out.println( path.toUri().toString() ); | ||
System.out.println( Paths.convert( path ).toURI() ); | ||
System.out.println( Paths.convert( Paths.convert( path ) ).toUri().toString() ); | ||
} | ||
|
||
{ | ||
final String FILENAME = "file+name.txt"; | ||
final org.uberfire.java.nio.file.Path path = org.uberfire.java.nio.file.Paths.get( "file://reponame/path/to/" ).resolve( FILENAME ); | ||
|
||
assertEquals( FILENAME, path.getFileName().toString() ); | ||
assertEquals( FILENAME, Paths.convert( path ).getFileName() ); | ||
assertEquals( FILENAME, Paths.convert( Paths.convert( path ) ).getFileName().toString() ); | ||
|
||
System.out.println( path.toUri().toString() ); | ||
System.out.println( Paths.convert( path ).toURI() ); | ||
System.out.println( Paths.convert( Paths.convert( path ) ).toUri().toString() ); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...uberfire-nio2-model/src/main/java/org/uberfire/java/nio/base/BasicFileAttributesUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.uberfire.java.nio.base; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.uberfire.java.nio.base.AbstractBasicFileAttributeView.*; | ||
|
||
public class BasicFileAttributesUtil { | ||
|
||
public static Map<String, Object> cleanup( final Map<String, Object> _attrs ) { | ||
final Map<String, Object> attrs = new HashMap<String, Object>( _attrs ); | ||
|
||
for ( final String key : _attrs.keySet() ) { | ||
if ( key.startsWith( IS_REGULAR_FILE ) || key.startsWith( IS_DIRECTORY ) || | ||
key.startsWith( IS_SYMBOLIC_LINK ) || key.startsWith( SIZE ) || | ||
key.startsWith( FILE_KEY ) || key.startsWith( IS_OTHER ) || | ||
key.startsWith( LAST_MODIFIED_TIME ) || key.startsWith( LAST_ACCESS_TIME ) || | ||
key.startsWith( CREATION_TIME ) ) { | ||
attrs.put( key, null ); | ||
} | ||
} | ||
|
||
return attrs; | ||
} | ||
|
||
} |