ruthst00 opened a new pull request, #6773: URL: https://github.com/apache/jmeter/pull/6773
…d quotes. ## Description <!--- Provide a general summary of your changes in the Title above --> <!--- Describe your changes in detail here --> __Fix (`BasicCurlParser.java`):__ Replaced the `StringTokenizer`-based loop with a character-level finite state machine that explicitly handles escape sequences: - In `inQuote` state: `\'` → literal `'`, stay in `inQuote` - In `inDoubleQuote` state: `\"` → literal `"`, stay in `inDoubleQuote` - In `normal` state: `` + `\r`/`\n` → line continuation (existing behaviour preserved) ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> __Root cause:__ `BasicCurlParser.translateCommandline` used `StringTokenizer` with quote characters as delimiters. A backslash-escaped quote inside a quoted token (e.g., `'tes\'t'` or `"tes\"t"`) caused the tokenizer to treat the escaped quote as a closing delimiter, leaving the remainder unbalanced and throwing `IllegalArgumentException: unbalanced quotes`. Fixes [#6374](https://github.com/apache/jmeter/issues/6374) ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, tests ran to see how --> <!--- your change affects other areas of the code, etc. --> __Tests added (`BasicCurlParserTest.java`)__ — 10 new tests in two groups: *Integration tests (parse-level, matching the issue's exact test cases):* - `testEscapedSingleQuoteInData` — `'tes\'t'` → post data `tes't` - `testEscapedDoubleQuoteInData` — `"tes\"t"` → post data `tes"t` *Direct unit tests for `translateCommandline`:* - `testTranslateCommandlineSimpleTokens` — plain space-separated tokens - `testTranslateCommandlineSingleQuotedToken` — single-quoted token with space - `testTranslateCommandlineDoubleQuotedToken` — double-quoted token with space - `testTranslateCommandlineEscapedSingleQuoteInsideSingleQuotes` — core fix: `'tes\'t'` → `tes't` - `testTranslateCommandlineEscapedDoubleQuoteInsideDoubleQuotes` — core fix: `"tes\"t"` → `tes"t` - `testTranslateCommandlineMultipleEscapedQuotes` — multiple `\'` in one token - `testTranslateCommandlineBackslashLineContinuation` — `\\\n` still works - `testTranslateCommandlineEmptyInput` — empty string → empty array - `testTranslateCommandlineUnbalancedQuotesStillThrows` — genuinely unbalanced quotes still throw ## Screenshots (if appropriate): ## Types of changes <!--- What types of changes does your code introduce? Delete as appropriate --> - Bug fix (non-breaking change which fixes an issue) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [X] My code follows the [code style][style-guide] of this project. - [X] I have updated the documentation accordingly. Generated with [Claude Sonnet](https://www.anthropic.com/claude/sonnet) via [Cline API Provider](https://cline.bot/) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
