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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to