mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-05-11 07:26:53 +00:00
fix: update filename sanitization to allow hyphens as literal characters
This commit is contained in:
@@ -16,7 +16,8 @@ final class MeshchatDownloadUtils {
|
||||
if (base.isEmpty()) {
|
||||
return "download.bin";
|
||||
}
|
||||
base = base.replaceAll("[^A-Za-z0-9._ -]+", "_").trim();
|
||||
// Hyphen must be first or last in the class so it is literal, not a range (space..hyphen would include '*').
|
||||
base = base.replaceAll("[^A-Za-z0-9._ \\-]+", "_").trim();
|
||||
if (base.isEmpty()) {
|
||||
return "download.bin";
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MeshchatDownloadUtilsTest {
|
||||
|
||||
@Test
|
||||
public void sanitize_replacesUnsafeCharacters() {
|
||||
Assert.assertEquals("mesh_x_folders.json", MeshchatDownloadUtils.sanitizeFileName("mesh:x?folders*.json"));
|
||||
Assert.assertEquals("mesh_x_folders_.json", MeshchatDownloadUtils.sanitizeFileName("mesh:x?folders*.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user