forked from go-yaml/yaml
-
Notifications
You must be signed in to change notification settings - Fork 1
Emosbaugh/20250908/rebase #4
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
Draft
emosbaugh
wants to merge
102
commits into
v2
Choose a base branch
from
emosbaugh/20250908/rebase
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New license in the README file.
An upstream change (http://golang.org/cl/31144) alters the time package to be more consistent about the representation of UTC location. We adjust the time.Time used in the test to work on both 1.7 and 1.8.
ParseFloat() accepts strings that contain digits with a single 'e' character somewhere in the middle as valid floats. The YAML spec does not accept these. This causes problems especially when dealing with short commit hashes, e.g. `123456e1`
func (e *encoder) marshal(tag string, in reflect.Value) should not try to perform any operations (call MarshalYAML() or MarshalText()) on nil pointers
Add UnmarshalStrict method returning error if yaml has fields that do not exist in structure
correct misspell
Add embedded structs example
Examples are nicer when they're shown in the godoc.
move embedded struct example into godoc
…-tags Fix for non-specific tags parsing
The current code uses "length" as a proxy for "has a tag" but the length doesn't actually match the length of the tag when there's a %-encoded character, so use a boolean instead. Also fix a panic found when trying to write a test for the change. Aside: seems that %-encoded tag handles are not allowed by the YAML spec.
Make tag scanning code slightly cleaner.
yaml.org describes several alternative formats for timestamps not covered by the default implementation of `time.UnmarshalText()`. These are handled explicitly in this change in resolve.go Timestamps will only be collected if there is an explicit timestamp tag (ie, not `!!str`) or if implicit type detection is enabled.
Factor the timestamp parsing into its own function that can easily be changed later to support the full range of time stamps and add a quick early check to avoid going through all the time.Parse calls in this common path. Also fix marshaling so that times are still printed unquoted.
Support usage of "~" to indicate null values for pointer types
include "yaml:" qualifier in Marshal docs. * Update yaml.go
Print the correct line number of YAML file if an unexpected field is found
Scanner errors are 0 indexed. Errors occuring on lines greater than 0, referenced the previous line in the error text. Fixes go-yaml#205.
Also performed in libyaml with yaml/libyaml@37c92e0
Currently, all float values are formatted using 64-bit, but that incorrectly formats float32 values like 0.01 and 0.99. See https://play.golang.org/p/jbseI1ivyMW for more context. Fixes go-yaml#352.
This commit adds support for encoding json.Number as a number instead of as a string, which is the underlying type of json.Number. Care has been taken to not introduce a dependency on the encoding/json package, by using an interface that specifies the methods of json.Number instead of the datatype itself. This also means that other packages that use a similar datatype will be supported. (Like json-iterator) This is useful for tools that wish to convert JSON data into YAML data by deserializing JSON into a map[string]interface{}, and use the json.Encoder's UseNumber() method, or structs that use the json.Number datatype and also wish to support yaml.
The regular expression is copy & pasted form the one in the spec. The change suggested in go-yaml#171 and integrated was improper. Closes go-yaml#290
Backport of caeefd8.
This addresses the following items: ==== Parse time of excessively deep nested or indented documents Parsing these documents is non-linear; limiting stack depth to 10,000 keeps parse times of pathological documents sub-second (~.25 seconds in benchmarks) ==== Alias node expansion limits The current limit allows 10,000% expansion, which is too permissive for large documents. Limiting to 10% expansion for larger documents allows callers to use input size as an effective way to limit resource usage. Continuing to allow larger expansion rates (up to the current 10,000% limit) for smaller documents does not unduly affect memory use. This change bounds decode operations from alias expansion to ~400,000 operations for small documents (worst-case ~100-150MB) or 10% of the input document for large documents, whichever is greater.
The problem does not affect v3.
This should simplify the logic and significantly improve performance in edge cases as found and reported on go-yaml#537 by CJ Cullen.
This change introduces an index to lookup token numbers referenced by simple_keys in O(1), thus significantly reducing the performance impact of certain abusively constructed snippets. When we build up the simple_keys stack, we count on the (formerly named) staleness check to catch errors where a simple key is required but would be > 1024 chars or span lines. The previous simplification that searches the stack from the top can go 1024 keys deep before finding a "stale" key and stopping. I added a test that shows that this consumes ~3s per 1MB of document size.
It was clearly a mistake to accept the default formatting change in v2, and now there's no ideal choice. Either we revert the change and break some projects twice, or we keep the change and break some projects once. Given the report comes from Kubernetes, which has a relevant community and code size, we'll revert it. At the same time, to simplify the life of those that already started migrating towards the v3 behavior, a new FutureLineWrap function is being introduced to trivially preserve the new behavior where desired. The v3 branch is not affected by this, and will retain the default non-wrapping behavior. It will also be changed soon to support per arbitrary line-wrapping for individual encoding operations. Thanks to everyone who offered code and ideas, and apologies for the trouble.
go.yaml.in/yaml/v2
Non-specific tag disables tag resolution, forcing the node to be interpreted as 'tag:yaml.org,2002:seq', 'tag:yaml.org,2002:map', or 'tag:yaml.org,2002:str' This fix pevents 'yaml_parser_scan_tag_uri' from raising an error if 'suffix' is empty. This case is handled by function 'yaml_parser_scan_tag', so this behaviour is expected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.