mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 23:38:49 +01:00
🎨 Limit KaTex macro maximum recursive parsing depth is 16 https://github.com/siyuan-note/siyuan/issues/10484
This commit is contained in:
parent
8615c5f1c4
commit
131d8b607c
2 changed files with 6 additions and 4 deletions
|
|
@ -910,6 +910,11 @@ func init() {
|
|||
|
||||
func resolveKaTexMacro(macroName string, macros *map[string]string, keys *[]string, depth *int) string {
|
||||
v := (*macros)[macroName]
|
||||
if *depth > 16 {
|
||||
// Limit KaTex macro maximum recursive parsing depth is 16 https://github.com/siyuan-note/siyuan/issues/10484
|
||||
return v
|
||||
}
|
||||
|
||||
sort.Slice(*keys, func(i, j int) bool { return len((*keys)[i]) > len((*keys)[j]) })
|
||||
*depth++
|
||||
for _, k := range *keys {
|
||||
|
|
@ -919,9 +924,6 @@ func resolveKaTexMacro(macroName string, macros *map[string]string, keys *[]stri
|
|||
v = unescapeKaTexSupportedFunctions(escaped)
|
||||
(*macros)[macroName] = v
|
||||
}
|
||||
if *depth > 16 {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue