This commit is contained in:
Daniel 2025-06-16 17:01:22 +08:00
parent 09f0fce4f4
commit 95ae34c7b1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 13 additions and 1 deletions

View file

@ -173,6 +173,7 @@ func getEmojiConf(c *gin.Context) {
if !util.IsValidUploadFileName(html.UnescapeString(name)) {
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
logging.LogWarnf("invalid custom emoji name [%s]", name)
continue
}
if customEmoji.IsDir() {

View file

@ -22,7 +22,6 @@ import (
"encoding/json"
"errors"
"fmt"
util2 "github.com/88250/lute/util"
"image"
"image/jpeg"
"image/png"
@ -44,6 +43,7 @@ import (
"github.com/88250/lute/html/atom"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
util2 "github.com/88250/lute/util"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/riff"
@ -557,6 +557,17 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
}
// 将包含的自定义表情统一移动到 data/emojis/ 下
filelock.Walk(filepath.Join(unzipRootPath, "emojis"), func(path string, d fs.DirEntry, err error) error {
if !util.IsValidUploadFileName(d.Name()) {
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
logging.LogErrorf("remove invalid file [%s] in emojis", path)
if removeErr := os.Remove(path); nil != removeErr {
logging.LogErrorf("remove invalid file [%s] failed: %s", path, removeErr)
return nil
}
}
return nil
})
var emojiDirs []string
filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error {
if strings.Contains(path, "emojis") && d.IsDir() {