-
Notifications
You must be signed in to change notification settings - Fork 204
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
Ensure strings that may be confused as YAML1.2 numbers are quoted #628
base: master
Are you sure you want to change the base?
Conversation
9ae719c
to
5279e18
Compare
assert_match(/'0o17'/, Psych.dump({'a' => '0o17'})) | ||
assert_match(/'0o111'/, Psych.dump({'a' => '0o111'})) | ||
|
||
# YAML 1.2 float Number | ||
assert_match(/'12e03'/, Psych.dump({'a' => '12e03'})) | ||
assert_match(/'1.2e3'/, Psych.dump({'a' => '1.2e3'})) | ||
assert_match(/".2e3"/, Psych.dump({'a' => '.2e3'})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
(any character) does not seem what you want here.
assert_match(/'0o17'/, Psych.dump({'a' => '0o17'})) | |
assert_match(/'0o111'/, Psych.dump({'a' => '0o111'})) | |
# YAML 1.2 float Number | |
assert_match(/'12e03'/, Psych.dump({'a' => '12e03'})) | |
assert_match(/'1.2e3'/, Psych.dump({'a' => '1.2e3'})) | |
assert_match(/".2e3"/, Psych.dump({'a' => '.2e3'})) | |
assert_include(Psych.dump({'a' => '0o17'}), "'0o17'") | |
assert_include(Psych.dump({'a' => '0o111'}), "'0o111'") | |
# YAML 1.2 float Number | |
assert_include(Psych.dump({'a' => '12e03'}), "'12e03'") | |
assert_include(Psych.dump({'a' => '1.2e3'}), "'1.2e3'") | |
assert_include(Psych.dump({'a' => '.2e3'}), '".2e3"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the last ".2e3"
seems from YAML 1.1, right?
@adammw Any chance you have time to continue working on this? I've run into this same problem where strings (git commit SHAs) that look like scientific notation are dumped with no quotes around them. |
Ensure strings that may be confused as YAML1.2 numbers are quoted.
Example:
0o123
or1e3
strings in Ruby will be printed without quotation marks, resulting in them changing to numbers in a YAML1.2-parser (like that used in Go).Fixes #627