File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
main/java/com/owncloud/android/utils
test/java/com/nextcloud/client/utils Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,8 @@ public static boolean containsBidiControlCharacters(String filename) {
8080 String decoded ;
8181 try {
8282 decoded = URLDecoder .decode (filename , StandardCharsets .UTF_8 .toString ());
83- } catch (UnsupportedEncodingException e ) {
84- return false ;
83+ } catch (Exception e ) {
84+ decoded = filename ;
8585 }
8686
8787 int [] bidiControlCharacters = {
Original file line number Diff line number Diff line change @@ -304,4 +304,22 @@ class FileStorageUtilsTest {
304304 val result = FileStorageUtils .containsBidiControlCharacters(" /Foo%e2%80%aedm.exe" )
305305 assertTrue(result)
306306 }
307+
308+ @Test
309+ fun testContainsBidiControlCharactersWhenGivenMalformedEncodedSequenceShouldNotThrowAndReturnFalse () {
310+ val result = FileStorageUtils .containsBidiControlCharacters(" file%" )
311+ assertFalse(result)
312+ }
313+
314+ @Test
315+ fun testContainsBidiControlCharactersWhenGivenBrokenUrlEncodedPatternShouldHandleGracefully () {
316+ val result = FileStorageUtils .containsBidiControlCharacters(" file%2" )
317+ assertFalse(result)
318+ }
319+
320+ @Test
321+ fun testContainsBidiControlCharactersWhenGivenMultipleBidiCharactersShouldReturnTrue () {
322+ val result = FileStorageUtils .containsBidiControlCharacters(" safe\u202E bad\u202B name.txt" )
323+ assertTrue(result)
324+ }
307325}
You can’t perform that action at this time.
0 commit comments