Skip to content

Conversation

emosbaugh
Copy link
Member

No description provided.

a-chernykh and others added 30 commits May 25, 2015 14:24
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
Examples are nicer when they're shown in the godoc.
move embedded struct example into godoc
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
vitreuz and others added 29 commits March 26, 2018 01:56
Scanner errors are 0 indexed. Errors occuring on lines greater than 0, referenced the previous line in the error text.

Fixes go-yaml#205.
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
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.
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.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.