Skip to content

Commit 4872d10

Browse files
committed
Sanitize attachment filenames by replacing slashes
Updated filename generation to replace forward and backward slashes in titles with underscores, ensuring filesystem-safe attachment filenames consistent with TiddlyWiki's behavior.
1 parent 6a16c93 commit 4872d10

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/tidgi-external-attachments/convertToExternalAttachment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ export async function convertToExternalAttachment(
6464

6565
const targetWikiFolderLocation = matchedWorkspace?.wikiFolderLocation ?? mainWikiFolderLocation;
6666

67-
// Generate filename from title or use title directly
67+
// Generate filename from title
6868
// Clean up the title to make it filesystem-safe
69-
let filename = title;
69+
// Replace forward/backward slashes with underscore (like TiddlyWiki does)
70+
let filename = title.replace(/\/|\\/g, '_');
7071

7172
// Get file extension from type
7273
const extensions = Object.keys($tw.config.fileExtensionInfo).filter(

src/tidgi-external-attachments/plugin.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"stability": "STABILITY_1_EXPERIMENTAL",
77
"plugin-type": "plugin",
88
"author": "LinOnetwo",
9-
"version": "1.10.0"
9+
"version": "1.10.1"
1010
}

0 commit comments

Comments
 (0)