-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix error with hash keys beginning with '-' #51
Conversation
Your example is a bit hard to follow because of the use of XXX, which also includes yaml encoding/decoding inside of it. |
I suspect the problem here is not that keys starting with
We'll need to look at what YAML::XS does to be sure. |
According to YAML spec:
So I believe that the dump done by YAML::Tiny is fine:
whereas
The patch I propose is necessary for YAML::Tiny to behave like YAML:
All the best |
YAML::Tiny fails to parse a hash where the key beigns with '-' (e.g. '-foo') with the error: YAML::Tiny found illegal characters in plain scalar: 'family: 'Courier 10 Pitch'' at test-yaml.pl line 21. Here's an example below, with a test program, the yaml file written by the test program and the result of the script: $ cat test-yaml.pl use strict; use warnings; use YAML::Tiny; use XXX; my $data = { '-weight' => 'normal', '-overstrike' => 0, '-size' => -13, '-slant' => 'roman', '-underline' => 0, '-family' => 'Courier 10 Pitch' }; my $config_file= 'test.yml'; my $config_yaml = YAML::Tiny->new ( { font => $data } ); $config_yaml->write($config_file); my $new_config = YAML::Tiny->read($config_file) ; YYY $new_config; devel$ cat test.yml --- font: -family: 'Courier 10 Pitch' -overstrike: 0 -size: -13 -slant: roman -underline: 0 -weight: normal devel$ perl test-yaml.pl YAML::Tiny found illegal characters in plain scalar: 'family: 'Courier 10 Pitch'' at test-yaml.pl line 21.
Could you rebase this against master please? You should be able to reopen and adjust the merge base at the top of this page. |
Hi Unfortunately, I cannot re-open this PR. Can you re-open it on your side ? All the best |
I cannot open it until/before the base branch has been changed (there is an option at the top of this PR page to do it) - it needs to be master, not devel. |
I don't have the option to change the base branch after I click on "edit" button. I can only change the title of the PR. I guess we're stuck. Would you like me to open another PR with the right target branch ? All the best |
Hello
YAML::Tiny fails to parse a hash where the key begins with '-' (e.g. '-foo'). YAML::Tiny fails with:
This PR contains a fix to this problem and a new test case for this style of hash keys.
Here's the test program that triggers this error:
The yaml file:
The result of the script with current version of YAML::Tiny:
And the result with the patch:
This patch also fixes RT #85045
All the best