Clean file names for belt and suspenders

This commit is contained in:
Moxie Marlinspike
2018-02-16 11:13:20 -08:00
parent 71c7ef5b5e
commit 6239508b39
3 changed files with 16 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util;
import android.os.Environment;
import android.support.annotation.Nullable;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
@@ -49,4 +50,13 @@ public class StorageUtil
public static File getDownloadDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_DOWNLOADS);
}
public static @Nullable String getCleanFileName(@Nullable String fileName) {
if (fileName == null) return null;
fileName = fileName.replace('\u202D', '\uFFFD');
fileName = fileName.replace('\u202E', '\uFFFD');
return fileName;
}
}