Incorrect parsing of options with escaped quotes
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 519
- Forks
- 129
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 1
Description
trying to parse the string:
const curl = `curl -X POST "https://api.example.com/data" -H "Content-Type: application/json" -d "{\\"key\\": \\"This string has an escaped backslash: \\\\ and a newline: \\\\n\\"}"`;
Which is equivalent to the valid curl command
curl -X POST "https://api.example.com/data" -H "Content-Type: application/json" -d "{\"key\": \"This string has an escaped backslash: \\ and a newline: \\n\"}"
But when I parse it, my args array looks like the following:
_: [
'curl',
'https://api.example.com/data',
'string',
'has',
'an',
'escaped',
'backslash:',
'\\\\',
'and',
'a',
'newline:',
'\\\\n\\"}"'
],
Am I missing something or is this a bug?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the exact JavaScript template string and parsing it with yargs-parser, then compare the resulting arguments with the expected curl arguments shown in the issue. Done means escaped quotes, backslashes, and the newline remain within the JSON argument instead of being split into separate arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100