mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-10 17:58:16 +00:00
perf(citation): optimize CITATION.cff rendering (#39575)
Rendering a CITATION.cff could use memory far out of proportion to the file, as every YAML alias copies its target into the formatted citation and the parser copies `%TAG` prefixes into every node. Files past these limits show no citation, like unparseable ones do today. - Skip files over 256 KiB, largest real-world file found is 80 KiB - Skip files with `%TAG` directives - Skip files whose aliases add more than 64 Ki nodes and value bytes - Skip self-referencing anchors, except a sequence listing itself Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
1 parent
9bb8751b29
commit
2705abf7f3
4 files changed
+85
-19
No files matched your search
@@ -124,6 +124,9 @@ func EntryFollowLinks(ctx context.Context, gitRepo *Repository, commit *Commit,
|
||||
if treeEntry.IsLink() {
|
||||
return res, util.ErrorWrap(util.ErrUnprocessableContent, "%q has too many links", firstFullPath)
|
||||
}
|
||||
if res == nil {
|
||||
res = &EntryFollowResult{TargetEntry: treeEntry, TargetFullPath: fullPath} // in case limit=0
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user