mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 03:16:51 +01:00
parent
7f1c0521ea
commit
df84927954
@ -318,6 +318,6 @@ public class FileUtils {
|
||||
* @return the valid file name
|
||||
*/
|
||||
public static String makeValidFileName(String name) {
|
||||
return name.replaceAll("\0/:\\r\\n\\\\", "_");
|
||||
return name.replaceAll("[\0/:\\r\\n\\\\]", "_");
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class FileUtilsTest extends TestBase {
|
||||
|
||||
@Test
|
||||
public void testValidFileName() {
|
||||
String tempName = "foo:bar";
|
||||
assertEquals("foo_bar", FileUtils.makeValidFileName(tempName));
|
||||
|
||||
tempName = "fo\no::bar";
|
||||
assertEquals("fo_o__bar", FileUtils.makeValidFileName(tempName));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user