-
Notifications
You must be signed in to change notification settings - Fork 151
Description
Describe the bug
When parsing a document with an unquoted string that "looks like" a number, the parser will use the float tag, even though the value cannot be represented by the JavaScript number and ends up getting stored as +Inf or -Inf.
To Reproduce
Steps to reproduce the behaviour:
> require("yaml").parse("gitsha: 61e9540")
{ gitsha: Infinity }Expected behaviour
Like some other YAML loaders (go-yaml comes to mind), an untagged, unquoted value should only be interpreted as a float if it can be safely stored as such in the native type.
Versions (please complete the following information):
- Environment: NodeJS 24.12.0
yaml: 2.8.1
Additional context
The YAML 1.2 spec is pretty clear:
Some languages (such as Perl) provide only a "number" type that allows for both integer and floating-point values. A YAML [processor] may use such a type for floating-point numbers, as long as they round-trip properly.