You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "ruthst00 (via GitHub)" <gi...@apache.org> on 2026/09/25 06:44:28 UTC
Re: [PR] Fixed issue where escaped characters in data of curl causes unbalanced quotes [jmeter]
ruthst00 commented on code in PR #6773:
URL: https://github.com/apache/jmeter/pull/6773#discussion_r4101897046
##########
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/BasicCurlParser.java:
##########
@@ -829,50 +829,79 @@ public static String[] translateCommandline(String toProcess) {
//no command? no string
return new String[0];
}
- // parse with a simple finite state machine
+ // parse with a character-level finite state machine so that
+ // backslash-escaped quotes inside a quoted token are handled correctly
+ // (e.g. 'tes\'t' or "tes\"t").
final int normal = 0;
final int inQuote = 1;
final int inDoubleQuote = 2;
int state = normal;
- final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
final ArrayList<String> result = new ArrayList<>();
final StringBuilder current = new StringBuilder();
boolean lastTokenHasBeenQuoted = false;
- while (tok.hasMoreTokens()) {
- String nextTok = tok.nextToken();
+ int i = 0;
+ final int len = toProcess.length();
+ while (i < len) {
+ char c = toProcess.charAt(i);
switch (state) {
case inQuote -> {
- if ("'".equals(nextTok)) {
+ if (c == '\\' && i + 1 < len && toProcess.charAt(i + 1) == '\'') {
Review Comment:
Fixed
--
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: dev-unsubscribe@jmeter.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org