mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🐛 File names ending with . will be considered as missing assets
🎨 Improve HTML clipping https://github.com/siyuan-note/siyuan/issues/13355
This commit is contained in:
parent
821a58d895
commit
22190b532d
8 changed files with 36 additions and 25 deletions
|
|
@ -97,21 +97,21 @@ func extensionCopy(c *gin.Context) {
|
|||
break
|
||||
}
|
||||
|
||||
ext := path.Ext(fName)
|
||||
originalExt := ext
|
||||
fName = util.FilterUploadFileName(fName)
|
||||
ext := util.Ext(fName)
|
||||
if "" == ext || strings.Contains(ext, "!") {
|
||||
// 改进浏览器剪藏扩展转换本地图片后缀 https://github.com/siyuan-note/siyuan/issues/7467
|
||||
if mtype := mimetype.Detect(data); nil != mtype {
|
||||
ext = mtype.Extension()
|
||||
fName += ext
|
||||
}
|
||||
}
|
||||
if "" == ext && bytes.HasPrefix(data, []byte("<svg ")) && bytes.HasSuffix(data, []byte("</svg>")) {
|
||||
ext = ".svg"
|
||||
fName += ext
|
||||
}
|
||||
|
||||
fName = fName[0 : len(fName)-len(originalExt)]
|
||||
fName = util.FilterUploadFileName(fName)
|
||||
fName = fName + "-" + ast.NewNodeID() + ext
|
||||
fName = util.AssetName(fName)
|
||||
writePath := filepath.Join(assets, fName)
|
||||
if err = filelock.WriteFile(writePath, data); err != nil {
|
||||
ret.Code = -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue