Skip to content

Conversation

@murthy-p
Copy link

@murthy-p murthy-p commented Feb 5, 2020

When a content of string contains empty qutoes and followed by a comment with a quote, the entire thing is getting matched, causing the comments to left over in the file
image
Modified regex for identifying the quotes
image

const constants = {
ESCAPED_CHAR_REGEX: /^\\./,
QUOTED_STRING_REGEX: /^(['"`])((?:\\.|[^\1])+?)(\1)/,
QUOTED_STRING_REGEX:/^(['"`])((?:|[^\1])+?)(\1)/,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after QUOTED_STRING_REGEX:

And I think the + should be inside, after the closing angle bracket ((?:[^\1]+)?) and remove the |

content: "Content At quoted String comments";
content: "";
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something bothers me about that file :D Why it has duplicate stuff? At least we can make it with different classes and different comments.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to replicate multiple scenarios. Will modify :)

rekmarks added a commit to MetaMask/snaps that referenced this pull request Jan 7, 2022
### Description
Based on the discussion ChainSafe/filsnap#88 and some further investigation, I realized that the problem origin is inside the library used for stripping comments. The problem occurs if there are double quotes inside the comment, and this issue has been created inside `strip-comments` lib (jonschlinkert/strip-comments#49). Unfortunately, this PR with the fix is stale for some time now, so inside our fork of snaps-cli we used a forked version of `strip-comments` library.

### Changes
In this PR I replaced `strip-comments` with our [fork](https://github.com/NodeFactoryIo/strip-comments) that:
 - fixes a bug with double quotes inside the comment
 - already contains types, so no need for importing them

Co-authored-by: Mak Muftic <mak@chainsafe.io>
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.

3 participants