Carleslc / Simple-YAML

This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
https://carleslc.me/Simple-YAML
GNU General Public License v3.0
130 stars 38 forks source link

Fix side comments in quotes #47

Closed LOOHP closed 2 years ago

LOOHP commented 3 years ago

This PR fixes the side comment parser from matching '#' signs inside of single and double quotes.

Fixes #42

Carleslc commented 2 years ago

Hello, thank you for your interest in Simple-YAML. Is this PR working? I see you have more commits on your master branch. I pretend to fix the issue with side comments for the next minor release.

LOOHP commented 2 years ago

The solution on my master branch does kinda solve the issue but I found that it isn't quite stable. I've noticed some parsing errors that might or might not be related to the changes I made, therefore I closed the PR. I haven't gotten around to taking a closer look at it yet.

I also feel like it is probably best for someone with a better knowledge of SnakeYaml & SimpleYaml to deal with this. Anyway, this bug is pretty much still around.

Here are a few test cases:

Key: "This is a string ''with a # character \"inside of it" # actual comment

It will think that this is the comment: character inside of it" # actual comment and the actual value will get cut off.

Key: "This is a string\" \" which got ''wrapped and also contains a #
    in its ''content."

Also, make sure when a fix is made, word wrapping is handled correctly. Especially when the wrapping happens right after a # character.

Carleslc commented 2 years ago

Seems hard to solve with regex, I guess that is why you removed the side regex all the way.

I have added some failing tests for comments, including the test cases you describe. They are in the fix-comments branch that I'm going to use to develop this fix.

I have also created a branch fix-comments-pr with the changes of this PR rebased over the fix-comments branch. With the changes of this PR some tests pass, but there are still some tests failing, so this PR will remain closed.

Carleslc commented 2 years ago

Here are a few test cases:

Key: "This is a string ''with a # character \"inside of it" # actual comment

It will think that this is the comment: character inside of it" # actual comment and the actual value will get cut off.

Key: "This is a string\" \" which got ''wrapped and also contains a #
    in its ''content."

Also, make sure when a fix is made, word wrapping is handled correctly. Especially when the wrapping happens right after a # character.

These test cases are now passing along with many other related test cases using the 1.8 release, see test-comments4.yml