-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony\Component\Yaml\Inline::evaluateScalar() breaks ISO 8601 dates #6275
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
Comments
The feature should not be removed as handling ISO 8601 values a dates is part of the YAML spec. If you want to keep the string, you have to quote it. |
I might not be a YAML expert, but how is converting a value that can or cannot (e.g. dates before 1970) be converted to a Unix timestamp to a Unix timestamp part of the specifications? I did a quick search of the 1.0, 1.1 and 1.2 documentation and couldn't find anything about special handling for ISO 8601 or Unix timestamps. |
@bartfeenstra Dates before 1970 are represented by negative numbers. See the PR I created with a test showing that dates before 1970 work. Are you having issues with this? |
This PR was merged into the master branch. Commits ------- 2f07966 [Yaml] Add test showing that dates before 01 Jan 1970 are correctly parsed Discussion ---------- [Yaml] Add test showing that dates before 01 Jan 1970 are correctly parsed Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Adds a test related to issue #6275, showing that the Yaml inline parsing supports ISO 8601 dates before 1980.
It appears that YYYY-MM-DD formats need to be quoted so Yaml doesn't convert them. YYYY-MM formats can be unquoted. My problems occured after manually altering some configuration files and not quoting YYYY-MM-DDD formats. A classic example of pebkac. Thank you, stof and asm89, for your time spent on this issue! Now that my issues are solved, I still have a few questions though:
|
@bartfeenstra because of the format specified in the YAML spec for timestamps: http://www.yaml.org/spec/1.2/spec.html#id2761573 |
…buh) This PR was merged into the 3.1-dev branch. Discussion ---------- [Yaml] support to parse and dump DateTime objects | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6275, #8580, #11838, #14420 | License | MIT | Doc PR | TODO Commits ------- 7e1c6c4 [Yaml] support to parse and dump DateTime objects
Symfony\Component\Yaml\Inline::evaluateScalar() uses Symfony\Component\Yaml\Inline::getTimestampRegex() to determine whether a scalar value contains a date in what seems to be the ISO 8601 format (getTimestampRegex() is badly documented) and if it does, it converts it to a Unix timestamp.
The problem is that this conversion is conceptually impossible for a number of reasons:
Suggested solution: remove the feature entirely.
The text was updated successfully, but these errors were encountered: