mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🔒 XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034 https://github.com/siyuan-note/siyuan/pull/15041
This commit is contained in:
parent
724cddf7cb
commit
e5a634d90c
2 changed files with 16 additions and 18 deletions
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
|
|
@ -171,13 +172,12 @@ func getEmojiConf(c *gin.Context) {
|
|||
}
|
||||
|
||||
if !util.IsValidUploadFileName(html.UnescapeString(name)) {
|
||||
emojiFullName := customConfDir + "/" + name
|
||||
fullPathFilteredName := customConfDir + "/" + util.FilterUploadFileName(name)
|
||||
emojiFullName := filepath.Join(customConfDir, name)
|
||||
fullPathFilteredName := filepath.Join(customConfDir, util.FilterUploadFileName(name))
|
||||
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||
logging.LogWarnf("invalid custom emoji name [%s]", name)
|
||||
logging.LogErrorf("renaming invalid file to [%s] in emojis", fullPathFilteredName)
|
||||
if removeErr := os.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
|
||||
logging.LogErrorf("renaming invalid file to [%s] failed: %s", fullPathFilteredName, removeErr)
|
||||
logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", name, fullPathFilteredName)
|
||||
if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
|
||||
logging.LogErrorf("renaming invalid custom emoji file to [%s] failed: %s", fullPathFilteredName, removeErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,13 +200,12 @@ func getEmojiConf(c *gin.Context) {
|
|||
}
|
||||
|
||||
if !util.IsValidUploadFileName(html.UnescapeString(name)) {
|
||||
emojiFullName := customConfDir + "/" + name
|
||||
fullPathFilteredName := customConfDir + "/" + util.FilterUploadFileName(name)
|
||||
emojiFullName := filepath.Join(customConfDir, name)
|
||||
fullPathFilteredName := filepath.Join(customConfDir, util.FilterUploadFileName(name))
|
||||
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||
logging.LogWarnf("invalid custom emoji name [%s]", name)
|
||||
logging.LogErrorf("renaming invalid file to [%s] in emojis", fullPathFilteredName)
|
||||
if removeErr := os.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
|
||||
logging.LogErrorf("renaming invalid file to [%s] failed: %s", fullPathFilteredName, removeErr)
|
||||
logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", name, fullPathFilteredName)
|
||||
if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
|
||||
logging.LogErrorf("renaming invalid custom emoji file to [%s] failed: %s", fullPathFilteredName, removeErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue