Skip to content

Commit 918d1bd

Browse files
committed
Signed-off-by: Daniel <845765@qq.com>
1 parent a245f75 commit 918d1bd

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

kernel/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
99
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
1010
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a
11-
github.com/88250/lute v1.7.7-0.20260321150117-91fef4014208
11+
github.com/88250/lute v1.7.7-0.20260329134828-30ee1cf08d47
1212
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
1313
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
1414
github.com/ConradIrwin/font v0.2.1

kernel/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
1414
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
1515
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a h1:s86WMolaqommXG1k2vXg9Gf1iXvgtHSdeD0eeJTQVR8=
1616
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a/go.mod h1:D+Db16m0N7r9MLZCMcj1a0ZsEGQAxDZkadOn79Gh0vI=
17-
github.com/88250/lute v1.7.7-0.20260321150117-91fef4014208 h1:XC08FBuhc2FTebSxE51xHg+u97+7buMfI6bjsHmHws8=
18-
github.com/88250/lute v1.7.7-0.20260321150117-91fef4014208/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
17+
github.com/88250/lute v1.7.7-0.20260329134828-30ee1cf08d47 h1:IoVGy/RDVpnBJWMtgaSffj8ch2XhLT57Z0poWcSw6eM=
18+
github.com/88250/lute v1.7.7-0.20260329134828-30ee1cf08d47/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
1919
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46 h1:Bq1JsDfVbHKUxNL/B2JXd8cC/1h6aFjrlXpGycnh0Hk=
2020
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
2121
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

kernel/model/file.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,9 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
740740
}
741741

742742
subTree.Root.AppendChild(n)
743+
for _, ial := range n.KramdownIAL {
744+
ial[1] = util.SanitizeAttr(ial[1])
745+
}
743746
}
744747

745748
luteEngine.RenderOptions.NodeIndexStart = index

kernel/util/misc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ func GetContainsSubStrs(s string, subStrs []string) (ret []string) {
212212
return
213213
}
214214

215+
func SanitizeAttr(attr string) string {
216+
attr = strings.TrimSpace(attr)
217+
h := "<div data-attr=\"" + attr + "\">"
218+
p := bluemonday.UGCPolicy()
219+
p.AllowDataAttributes()
220+
ret := p.Sanitize(h)
221+
ret = strings.TrimPrefix(ret, "<div data-attr=\"")
222+
ret = strings.TrimSuffix(ret, "\">")
223+
return ret
224+
}
225+
215226
func SanitizeImgSrc(src string) string {
216227
src = strings.TrimSpace(src)
217228
h := "<img src=\"" + src + "\">"

0 commit comments

Comments
 (0)