🎨 限制文档名称最大长度为 512 https://github.com/siyuan-note/siyuan/issues/6299

This commit is contained in:
Liang Ding 2022-10-22 01:25:22 +08:00
parent f9784e2b83
commit cff937a384
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 16 additions and 5 deletions

View file

@ -901,7 +901,7 @@
"103": "The update installation package has been automatically downloaded in the background. When exiting, you will be asked whether to install the new version",
"104": "The update installation package failed to download, please check the network connection",
"105": "Corrupted data repo have been automatically reset",
"106": "TODO",
"106": "The maximum length of the document name is 512 characters",
"107": "Moving document [%s]",
"108": "Cleaning obsolete indexes...",
"109": "Remove reminder completed [%s]",

View file

@ -901,7 +901,7 @@
"103": "El paquete de instalación de la actualización se ha descargado automáticamente en segundo plano. Al salir, se le preguntará si desea instalar la nueva versión",
"104": "El paquete de instalación de la actualización no se pudo descargar, verifique la conexión de red",
"105": "El repositorio de datos corruptos se ha restablecido automáticamente",
"106": "TODO",
"106": "La longitud máxima del nombre del documento es de 512 caracteres.",
"107": "Moviendo documento [%s]",
"108": "Limpiando índices obsoletos...",
"109": "Eliminación de recordatorios completada [%s]",

View file

@ -901,7 +901,7 @@
"103": "Le package d'installation de la mise à jour a été automatiquement téléchargé en arrière-plan. En quittant, il vous sera demandé si vous souhaitez installer la nouvelle version",
"104": "Le package d'installation de la mise à jour n'a pas pu être téléchargé, veuillez vérifier la connexion réseau",
"105": "Le référentiel de données corrompu a été automatiquement réinitialisé",
"106": "TODO",
"106": "La longueur maximale du nom du document est de 512 caractères",
"107": "Déplacement du document [%s]",
"108": "Nettoyage des index obsolètes...",
"109": "Supprimer le rappel terminé [%s]",

View file

@ -901,7 +901,7 @@
"103": "已經在後台開始自動下載更新安裝包,退出時將詢問是否安裝新版本",
"104": "更新安裝包下載失敗,請檢查網絡連接",
"105": "已經自動重置損壞的數據倉庫",
"106": "TODO",
"106": "文檔名最大長度限制為 512 字符",
"107": "正在移動文檔 [%s]",
"108": "正在清理已過時的索引...",
"109": "移除提醒完畢 [%s]",

View file

@ -901,7 +901,7 @@
"103": "已经在后台开始自动下载更新安装包,退出时将询问是否安装新版本",
"104": "更新安装包下载失败,请检查网络连接",
"105": "已经自动重置损坏的数据仓库",
"106": "TODO",
"106": "文档名最大长度限制为 512 字符",
"107": "正在移动文档 [%s]",
"108": "正在清理已过时的索引...",
"109": "移除提醒完毕 [%s]",

View file

@ -29,6 +29,7 @@ import (
"strconv"
"strings"
"time"
"unicode/utf8"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
@ -1268,6 +1269,11 @@ func RenameDoc(boxID, p, title string) (err error) {
}
title = gulu.Str.RemoveInvisible(title)
if 512 < utf8.RuneCountInString(title) {
// 限制文档名称最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return errors.New(Conf.Language(106))
}
oldTitle := tree.Root.IALAttr("title")
if oldTitle == title {
return
@ -1386,6 +1392,11 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
func createDoc(boxID, p, title, dom string) (err error) {
title = gulu.Str.RemoveInvisible(title)
if 512 < utf8.RuneCountInString(title) {
// 限制文档名称最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return errors.New(Conf.Language(106))
}
baseName := strings.TrimSpace(path.Base(p))
if "" == strings.TrimSuffix(baseName, ".sy") {
return errors.New(Conf.Language(16))