mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
00cbc80b91
9 changed files with 70 additions and 9 deletions
|
|
@ -626,13 +626,18 @@ func getBlockInfo(c *gin.Context) {
|
||||||
}
|
}
|
||||||
rootTitle := root.IAL["title"]
|
rootTitle := root.IAL["title"]
|
||||||
rootTitle = html.UnescapeString(rootTitle)
|
rootTitle = html.UnescapeString(rootTitle)
|
||||||
|
icon := root.IAL["icon"]
|
||||||
|
if strings.Contains(icon, ".") {
|
||||||
|
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||||
|
icon = util.FilterUploadFileName(icon)
|
||||||
|
}
|
||||||
ret.Data = map[string]string{
|
ret.Data = map[string]string{
|
||||||
"box": block.Box,
|
"box": block.Box,
|
||||||
"path": block.Path,
|
"path": block.Path,
|
||||||
"rootID": block.RootID,
|
"rootID": block.RootID,
|
||||||
"rootTitle": rootTitle,
|
"rootTitle": rootTitle,
|
||||||
"rootChildID": rootChildID,
|
"rootChildID": rootChildID,
|
||||||
"rootIcon": root.IAL["icon"],
|
"rootIcon": icon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -654,7 +654,12 @@ func setEmoji(c *gin.Context) {
|
||||||
argEmoji := arg["emoji"].([]interface{})
|
argEmoji := arg["emoji"].([]interface{})
|
||||||
var emoji []string
|
var emoji []string
|
||||||
for _, ae := range argEmoji {
|
for _, ae := range argEmoji {
|
||||||
emoji = append(emoji, ae.(string))
|
e := ae.(string)
|
||||||
|
if strings.Contains(e, ".") {
|
||||||
|
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||||
|
e = util.FilterUploadFileName(e)
|
||||||
|
}
|
||||||
|
emoji = append(emoji, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
model.Conf.Editor.Emoji = emoji
|
model.Conf.Editor.Emoji = emoji
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ type Gallery struct {
|
||||||
|
|
||||||
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源
|
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源
|
||||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效
|
CoverFromAssetKeyID string `json:"coverFromAssetKeyID,omitempty"` // 资源字段 ID,CoverFrom 为 CoverFromAssetField 时有效
|
||||||
|
CardAspectRatio CardAspectRatio `json:"cardAspectRatio"` // 卡片宽高比
|
||||||
CardSize CardSize `json:"cardSize"` // 卡片大小
|
CardSize CardSize `json:"cardSize"` // 卡片大小
|
||||||
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
|
FitImage bool `json:"fitImage"` // 是否适应封面图片大小
|
||||||
ShowIcon bool `json:"showIcon"` // 是否显示字段图标
|
ShowIcon bool `json:"showIcon"` // 是否显示字段图标
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,36 @@ import (
|
||||||
"github.com/xrash/smetrics"
|
"github.com/xrash/smetrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (tx *Transaction) doSetAttrViewCardAspectRatio(operation *Operation) (ret *TxErr) {
|
||||||
|
err := setAttrViewCardSize(operation)
|
||||||
|
if err != nil {
|
||||||
|
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func setAttrViewCardAspectRatio(operation *Operation) (err error) {
|
||||||
|
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
view, err := getAttrViewViewByBlockID(attrView, operation.BlockID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch view.LayoutType {
|
||||||
|
case av.LayoutTypeTable:
|
||||||
|
return
|
||||||
|
case av.LayoutTypeGallery:
|
||||||
|
view.Gallery.CardAspectRatio = av.CardAspectRatio(operation.Data.(float64))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = av.SaveAttributeView(attrView)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doSetAttrViewBlockView(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doSetAttrViewBlockView(operation *Operation) (ret *TxErr) {
|
||||||
err := SetDatabaseBlockView(operation.BlockID, operation.AvID, operation.ID)
|
err := SetDatabaseBlockView(operation.BlockID, operation.AvID, operation.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -699,6 +699,11 @@ func ChangeBoxSort(boxIDs []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetBoxIcon(boxID, icon string) {
|
func SetBoxIcon(boxID, icon string) {
|
||||||
|
if strings.Contains(icon, ".") {
|
||||||
|
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||||
|
icon = util.FilterUploadFileName(icon)
|
||||||
|
}
|
||||||
|
|
||||||
box := &Box{ID: boxID}
|
box := &Box{ID: boxID}
|
||||||
boxConf := box.GetConf()
|
boxConf := box.GetConf()
|
||||||
boxConf.Icon = icon
|
boxConf.Icon = icon
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,13 @@ func InitConf() {
|
||||||
if 1 > len(Conf.Editor.Emoji) {
|
if 1 > len(Conf.Editor.Emoji) {
|
||||||
Conf.Editor.Emoji = []string{}
|
Conf.Editor.Emoji = []string{}
|
||||||
}
|
}
|
||||||
|
for i, emoji := range Conf.Editor.Emoji {
|
||||||
|
if strings.Contains(emoji, ".") {
|
||||||
|
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||||
|
emoji = util.FilterUploadFileName(emoji)
|
||||||
|
Conf.Editor.Emoji[i] = emoji
|
||||||
|
}
|
||||||
|
}
|
||||||
if 9 > Conf.Editor.FontSize || 72 < Conf.Editor.FontSize {
|
if 9 > Conf.Editor.FontSize || 72 < Conf.Editor.FontSize {
|
||||||
Conf.Editor.FontSize = 16
|
Conf.Editor.FontSize = 16
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,12 @@ func (box *Box) docFromFileInfo(fileInfo *FileInfo, ial map[string]string) (ret
|
||||||
ret.Path = fileInfo.path
|
ret.Path = fileInfo.path
|
||||||
ret.Size = uint64(fileInfo.size)
|
ret.Size = uint64(fileInfo.size)
|
||||||
ret.Name = ial["title"] + ".sy"
|
ret.Name = ial["title"] + ".sy"
|
||||||
ret.Icon = ial["icon"]
|
icon := ial["icon"]
|
||||||
|
if strings.Contains(icon, ".") {
|
||||||
|
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
|
||||||
|
icon = util.FilterUploadFileName(icon)
|
||||||
|
}
|
||||||
|
ret.Icon = icon
|
||||||
ret.ID = ial["id"]
|
ret.ID = ial["id"]
|
||||||
ret.Name1 = ial["name"]
|
ret.Name1 = ial["name"]
|
||||||
ret.Alias = ial["alias"]
|
ret.Alias = ial["alias"]
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
||||||
ret = tx.doChangeAttrViewLayout(op)
|
ret = tx.doChangeAttrViewLayout(op)
|
||||||
case "setAttrViewBlockView":
|
case "setAttrViewBlockView":
|
||||||
ret = tx.doSetAttrViewBlockView(op)
|
ret = tx.doSetAttrViewBlockView(op)
|
||||||
|
case "setAttrViewCardAspectRatio":
|
||||||
|
ret = tx.doSetAttrViewCardAspectRatio(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != ret {
|
if nil != ret {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
||||||
},
|
},
|
||||||
CoverFrom: view.Gallery.CoverFrom,
|
CoverFrom: view.Gallery.CoverFrom,
|
||||||
CoverFromAssetKeyID: view.Gallery.CoverFromAssetKeyID,
|
CoverFromAssetKeyID: view.Gallery.CoverFromAssetKeyID,
|
||||||
|
CardAspectRatio: view.Gallery.CardAspectRatio,
|
||||||
CardSize: view.Gallery.CardSize,
|
CardSize: view.Gallery.CardSize,
|
||||||
FitImage: view.Gallery.FitImage,
|
FitImage: view.Gallery.FitImage,
|
||||||
ShowIcon: view.Gallery.ShowIcon,
|
ShowIcon: view.Gallery.ShowIcon,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue