-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[YAML] Parsing octal numbers: unexpected value conversion and PHP 7.4 notice #34807
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
According to https://yaml.org/spec/1.2/spec.html#id2805071, only values matching the regex |
Yaml 1.1 has a similar restriction about |
PHP 7.4 compat will be fixed by #36690 on the |
#34813 now deprecates the 1.1 notation and adds support for the 1.2 notation. |
… (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] prevent notice for invalid octal numbers on PHP 7.4 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34807 | License | MIT | Doc PR | Commits ------- 92bc19f prevent notice for invalid octal numbers on PHP 7.4
Symfony version(s) affected: probably all (tried 4.3 and 4.4)
Description
Parsing YAML values that start with 0 may result in a deprecation warning in PHP 7.4:
Related note in PHP 7.4 migration guide: https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.invalid-base-characters
Also unsure if the parsing happens correctly according to the YAML spec.
Having something like
OwnerId: 0123456789
in YAML, it is being interpreted as an octal number and results in[OwnerId] => 342391
when parsed.How to reproduce
results in:
342391
decimal, when converted back to ocal however is1234567
in octal, not0123456789
, which is obvious, because0123456789
is not a valid octal number.Possible Solution
As far as I see, the yaml spec is not clear about how to handle this case. Many users might be unaware of this conversion and actually expect a string '0123456789' as the parseing result. So we should probably add a check and only convert octal numbers that are valid.
I also found that YAML 1.1 is showing octal number examples like
013
but YAML 1.2 they are0o14
...Additional context
related code:
symfony/src/Symfony/Component/Yaml/Inline.php
Lines 625 to 634 in c732122
The text was updated successfully, but these errors were encountered: