Skip to content
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

Relax Pure::Parser's comment regex to allow any characters in a multi-line comment #492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sjahu
Copy link

@sjahu sjahu commented Feb 10, 2022

The regex used by Pure::Parser for ignoring comments in JSON tries to do some fancy handling to prohibit nested comments, but it causes it to choke on strings that would otherwise be legit (i.e. that can be parsed by Ext::Parser or by a C compiler).

For example, a couple strings that are parsed correctly by Ext::Parser but not Pure::Parser:
image

This is the original regex (visualized by Regexper):
image

This is the simplified regex after my changes (Regexper):
image

I added a test to assert that a comment containing /* is parseable. Note that the test case immediately above that change asserts that a nested ANSI C-style comment still triggers an exception.

...to allow any character sequence, including "/*", before then end
sequence of a multi-line ANSI C-style comment
.
@sjahu
Copy link
Author

sjahu commented Feb 10, 2022

(CI hasn't run because "First-time contributors need a maintainer to approve running workflows.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant