YAML.safe_load fails when a string contains a non-existent date
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 597
- Forks
- 223
- Avg merge
- 11h 23m
- Merged PRs (30d)
- 3
Description
YAML.safe_load will raise an exception when you try to load text that happens to contain a sequence of numbers that looks like a date but is not:
s="2016-02-31"
YAML.safe_load(s.to_yaml)
# => Psych::DisallowedClass: Tried to load unspecified class: Date
Using YAML.load instead of safe_load works fine and text that contains a correct date works fine too. But this can be used to raise an exception on any application that uses YAML.safe_load on user provided text (accidentally or otherwise)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the YAML.safe_load example with the invalid date string and compare it with YAML.load and a valid date. Trace Psych's safe_load handling of date-like scalar values; done means malformed date-looking text no longer raises the reported exception while safe loading remains protected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100