🎨 Improve database text, email, url and phone field content escaping https://github.com/siyuan-note/siyuan/issues/11255

This commit is contained in:
Daniel 2024-05-08 19:52:10 +08:00
parent aa6340541b
commit 83209e6ab2
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 26 additions and 2 deletions

View file

@ -1087,10 +1087,22 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
if nil != tableCell.Value && nil != tableCell.Value.Relation {
tableCell.Value.Relation.Contents = nil
}
case av.KeyTypeText: // 渲染文本列
case av.KeyTypeText:
if nil != tableCell.Value && nil != tableCell.Value.Text {
tableCell.Value.Text.Content = util.EscapeHTML(tableCell.Value.Text.Content)
}
case av.KeyTypeEmail:
if nil != tableCell.Value && nil != tableCell.Value.Email {
tableCell.Value.Email.Content = util.EscapeHTML(tableCell.Value.Email.Content)
}
case av.KeyTypeURL:
if nil != tableCell.Value && nil != tableCell.Value.URL {
tableCell.Value.URL.Content = util.EscapeHTML(tableCell.Value.URL.Content)
}
case av.KeyTypePhone:
if nil != tableCell.Value && nil != tableCell.Value.Phone {
tableCell.Value.Phone.Content = util.EscapeHTML(tableCell.Value.Phone.Content)
}
}
treenode.FillAttributeViewTableCellNilValue(tableCell, rowID, col.ID)

View file

@ -722,10 +722,22 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
if nil != tableCell.Value && nil != tableCell.Value.Relation {
tableCell.Value.Relation.Contents = nil
}
case av.KeyTypeText: // 渲染文本列
case av.KeyTypeText:
if nil != tableCell.Value && nil != tableCell.Value.Text {
tableCell.Value.Text.Content = util.EscapeHTML(tableCell.Value.Text.Content)
}
case av.KeyTypeEmail:
if nil != tableCell.Value && nil != tableCell.Value.Email {
tableCell.Value.Email.Content = util.EscapeHTML(tableCell.Value.Email.Content)
}
case av.KeyTypeURL:
if nil != tableCell.Value && nil != tableCell.Value.URL {
tableCell.Value.URL.Content = util.EscapeHTML(tableCell.Value.URL.Content)
}
case av.KeyTypePhone:
if nil != tableCell.Value && nil != tableCell.Value.Phone {
tableCell.Value.Phone.Content = util.EscapeHTML(tableCell.Value.Phone.Content)
}
}
FillAttributeViewTableCellNilValue(tableCell, rowID, col.ID)