Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5794

Vanessa71678ad217b0
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 86c882f9b4..843b558499 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -476,10 +476,9 @@ export const openBy = (url: string, type: "folder" | "app") => {
} else {
address = url.replace("file://", "");
}
+ // 拖入文件名包含 `)` 、`(` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
+ address = address.replace(/\\\)/g, ")").replace(/\\\(/g, "(");
if (type === "app") {
- // 拖入文件名包含 `)` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
- address = address.replace(/\\\)/g, ")")
-
shell.openPath(address);
} else if (type === "folder") {
shell.showItemInFolder(address);
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 0775b8e40a..5a341d9c52 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -717,13 +717,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (event.altKey) {
let fileText = "";
files.forEach((item) => {
- fileText += `[${path.basename(item)}](file://${item})\n`;
+ // 拖入文件名包含 `)` 或 `]` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
+ fileText += `[${path.basename(item.replace(/\]/g, "\\]").replace(/\[/g, "\\["))}](file://${item.replace(/\)/g, "\\)").replace(/\(/g, "\\(")})\n`;
});
-
- // 拖入文件名包含 `)` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
- fileText = fileText.replace(/\)/g, "\\)");
- fileText = fileText.substring(0, fileText.length - 3) + ")"
-
insertHTML(protyle.lute.SpinBlockDOM(fileText), protyle);
} else {
uploadLocalFiles(files, protyle);