You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2018/07/27 19:27:11 UTC

[GitHub] KathrynN commented on a change in pull request #4: [MSHARED-750] - Unbalanced quotes in command with escaped double quot…

KathrynN commented on a change in pull request #4: [MSHARED-750] - Unbalanced quotes in command with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#discussion_r205876736
 
 

 ##########
 File path: src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
 ##########
 @@ -490,31 +491,65 @@ private static boolean isAlive( Process p )
                 case inQuote:
                     if ( "\'".equals( nextTok ) )
                     {
-                        state = normal;
+                        if ( inEscape )
+                        {
+                            current.append( nextTok );
+                            inEscape = false;
+                        }
+                        else
+                        {
+                            state = normal;
+                        }
                     }
                     else
                     {
                         current.append( nextTok );
+                        inEscape = "\\".equals( nextTok );
                     }
                     break;
                 case inDoubleQuote:
                     if ( "\"".equals( nextTok ) )
                     {
-                        state = normal;
+                        if ( inEscape )
+                        {
+                            current.append( nextTok );
+                            inEscape = false;
+                        }
+                        else
+                        {
+                            state = normal;
+                        }
                     }
                     else
                     {
                         current.append( nextTok );
+                        inEscape = "\\".equals( nextTok );
                     }
                     break;
                 default:
                     if ( "\'".equals( nextTok ) )
                     {
-                        state = inQuote;
+                        if ( inEscape )
+                        {
+                            inEscape = false;
+                            current.append( nextTok );
+                        }
+                        else
+                        {
+                            state = inQuote;
+                        }
                     }
                     else if ( "\"".equals( nextTok ) )
                     {
-                        state = inDoubleQuote;
+                        if ( inEscape )
 
 Review comment:
   If anyone has a tidier way to do this, it would be much appreciated!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services