Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] support auto anchor option #606

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

[WIP] support auto anchor option #606

wants to merge 5 commits into from

Conversation

goccy
Copy link
Owner

@goccy goccy commented Dec 23, 2024

resolve #461

yaml.UseAutoAnchor() option automatically assigns an anchor name to a value when the same pointer address is found during encoding and uses an alias for reference points

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 78.28571% with 38 lines in your changes missing coverage. Please review.

Project coverage is 77.19%. Comparing base (9cbf5d4) to head (d3d0468).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #606      +/-   ##
==========================================
- Coverage   77.21%   77.19%   -0.03%     
==========================================
  Files          22       22              
  Lines        7870     7966      +96     
==========================================
+ Hits         6077     6149      +72     
- Misses       1374     1393      +19     
- Partials      419      424       +5     

@bep
Copy link

bep commented Dec 23, 2024

@goccy This is a great option that I (and I suspect many others) would really want, I don't see how it fixes #461.

The printing problem I'm talking about isn't (just) marshaling it back to YAML. There's a lot of potential printing going on in Hugo. E.g. to JSON, or templates:

{{ range $k, $v := $frontmatter }}
   {{ printf "%s: %s" $k $v }}
{{ end }}

So what I had in mind was an option to detect malicious/insensible YAML documents and throw an error. I have reopened the upstream PR about this gohugoio/hugo#13033 -- I'm thinking it should be possible to add some "sanity checks" on the unmarshaled Go map.

But again, an auto anchor option is still a great idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Security issue: Parsing malicious or large YAML documents can consume excessive amounts of CPU or memory.
3 participants