-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Tighten restrictions on float decoding #171
Conversation
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` This regex isn't exactly the same as the YAML spec. It continues to allow decimals like `0.1` to be parsed as floats.
Signed the individual agreement as we don't have an org-wide one set up. |
@niemeyer Just wanted to ping you on this, I realized that I edited the comment but that may not have generated a new notification. |
Could really use this. It prevents yaml generated from other languages from being consumed by Go. |
@niemeyer Since the license changed, should I close and resubmit this PR? I'm fine with my change being Apache 2 licensed, so I can also leave it as is. |
Thanks, and sorry for the long delay. |
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`
* v/fix-for-issue-91: (40 commits) Add test cases from go-yaml#184 Fix for issue go-yaml#91 Fixes go-yaml#214 - New option to allow setting strict boolean mode Fix for issue go-yaml#144 Always use the pointer mechanism, but only allow recursion per option Applied API changes as suggested in another PR and fixed outstanding problems Removed introduced shadowing bug Make aliases share the same memory address as the anchor ( go-yaml#215 ) Replace LICENSE text with actual license (go-yaml#274) Make tag scanning code slightly cleaner. move embedded struct example into godoc Add UnmarshalStrict returning error if yaml has fields that do not exist in structure correct misspell on yamlh.go fix misspell on emmiterc.go Remove unreachable code to fix go vet (go-yaml#249) Fix dead URL for yaml specification (go-yaml#240) Tighten restrictions on float decoding (go-yaml#171) Fix decode test for Go 1.8 (go-yaml#217) Fix unmarshaler handling of empty strings. new license in the README file (go-yaml#189) ...
full diff: go-yaml/yaml@v2.2.2...v2.2.7 includes: - go-yaml/yaml@caeefd8 addresses CVE-2019-11253 JSON/YAML parsing vulnerable to resource exhaustion attack - go-yaml/yaml#171 Tighten restrictions on float decoding - go-yaml/yaml#515 Add large document benchmarks, tune alias heuristic, add max depth limits - go-yaml/yaml@f90ceb4 fixes go-yaml/yaml#529 yaml.Unmarshal crashes on "assignment to entry in nil map" - go-yaml/yaml#543 Port stale simple_keys fix to v2 - go-yaml/yaml@1f64d61 fixes go-yaml/yaml#548 Invalid simple_keys now cause panics later in decode Signed-off-by: Sebastiaan van Stijn <[email protected]>
full diff: go-yaml/yaml@v2.2.2...v2.2.7 includes: - go-yaml/yaml@caeefd8 addresses CVE-2019-11253 JSON/YAML parsing vulnerable to resource exhaustion attack - go-yaml/yaml#171 Tighten restrictions on float decoding - go-yaml/yaml#515 Add large document benchmarks, tune alias heuristic, add max depth limits - go-yaml/yaml@f90ceb4 fixes go-yaml/yaml#529 yaml.Unmarshal crashes on "assignment to entry in nil map" - go-yaml/yaml#543 Port stale simple_keys fix to v2 - go-yaml/yaml@1f64d61 fixes go-yaml/yaml#548 Invalid simple_keys now cause panics later in decode Signed-off-by: Sebastiaan van Stijn <[email protected]>
The regular expression is copy & pasted form the one in the spec. The change suggested in go-yaml/yaml#171 and integrated was improper. Closes go-yaml/yaml#290 (cherry-pick of go-yaml/yaml@7b8349a) Signed-off-by: John Ryan <[email protected]>
Parse floats correctly and fix mistake from go-yaml/yaml#171
The Golang checks for floats are more permissive than the YAML spec, causing problems when reading in commit hashes (strings) that are occasionally confused with floats. This change also matches the Ruby and Python implementations' behaviour.