[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561081#comment-16561081
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408669225
 
 
   Hi Kathryn, If you look on the repository on master you see the your image 
...which means GitHub has identified it correctly..Thanks for fixing this...


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561082#comment-16561082
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise edited a comment on issue #4: [MSHARED-750] - Unbalanced quotes in 
command with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408669225
 
 
   Hi Kathryn, If you look on the repository on master you see the your image 
...which means GitHub has identified it correctly..Thanks for fixing this...
   
   https://github.com/apache/maven-shared-utils/commits/master


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561078#comment-16561078
 ] 

ASF GitHub Bot commented on MSHARED-750:


KathrynN commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408668591
 
 
   Was the email better this time?
   Thank you for your swift response!


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561075#comment-16561075
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise closed pull request #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java 
b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
index 4beea13..3a745ab 100644
--- a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
@@ -477,8 +477,9 @@ private static boolean isAlive( Process p )
 final int normal = 0;
 final int inQuote = 1;
 final int inDoubleQuote = 2;
+boolean inEscape = false;
 int state = normal;
-StringTokenizer tok = new StringTokenizer( toProcess, "\"\' ", true );
+final StringTokenizer tok = new StringTokenizer( toProcess, "\"\' \\", 
true );
 List tokens = new ArrayList();
 StringBuilder current = new StringBuilder();
 
@@ -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 )
+{
+inEscape = false;
+current.append( nextTok );
+}
+else
+{
+state = inDoubleQuote;
+}
 }
 else if ( " ".equals( nextTok ) )
 {
@@ -527,6 +562,7 @@ else if ( " ".equals( nextTok ) )
 else
 {
 current.append( nextTok );
+inEscape = "\\".equals( nextTok );
 }
 break;
 }
diff --git 
a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java 
b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
index 4ed35ed..d64fdd8 100644
--- a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
@@ -22,6 +22,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -99,27 +100,38 @@ public void 

[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread Hudson (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561073#comment-16561073
 ] 

Hudson commented on MSHARED-750:


Build succeeded in Jenkins: Maven TLP » maven-shared-utils » master #18

See 
https://builds.apache.org/job/maven-box/job/maven-shared-utils/job/master/18/

> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561074#comment-16561074
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408668073
 
 
   Successful build. Also merged into master
   * 
https://gitbox.apache.org/repos/asf?p=maven-shared-utils.git;a=commitdiff;h=336594396f2e9be8a572100e30a611f8123a837d
   * https://issues.apache.org/jira/browse/MSHARED-750
   
   Thanks for your contribution.


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread Karl Heinz Marbaise (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561072#comment-16561072
 ] 

Karl Heinz Marbaise commented on MSHARED-750:
-

Thanks for the contribution by Kathryn Newbould.

> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Affects Versions: maven-shared-utils-3.2.1
>Reporter: Kathryn Newbould
>Assignee: Karl Heinz Marbaise
>Priority: Major
> Fix For: maven-shared-utils-3.3.0
>
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread Karl Heinz Marbaise (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561071#comment-16561071
 ] 

Karl Heinz Marbaise commented on MSHARED-750:
-

Done in 
[336594396f2e9be8a572100e30a611f8123a837d|https://gitbox.apache.org/repos/asf?p=maven-shared-utils.git;a=commitdiff;h=336594396f2e9be8a572100e30a611f8123a837d]

> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561068#comment-16561068
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-40876
 
 
   So lets see what CI says... 
https://builds.apache.org/view/M-R/view/Maven/job/maven-box/job/maven-shared-utils/job/MSHARED-750/


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561067#comment-16561067
 ] 

ASF GitHub Bot commented on MSHARED-750:


KathrynN commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408666149
 
 
   Yep!  As soon as you're happy with it. 


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16561056#comment-16561056
 ] 

ASF GitHub Bot commented on MSHARED-750:


khmarbaise commented on issue #4: [MSHARED-750] - Unbalanced quotes in command 
with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4#issuecomment-408664076
 
 
   Is this ready for integration from your side ? 


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to MSHARED-749, the following test will error (due to an exception being 
> thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560172#comment-16560172
 ] 

ASF GitHub Bot commented on MSHARED-750:


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to [MSHARED_749], the following test will error (due to an exception 
> being thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560173#comment-16560173
 ] 

ASF GitHub Bot commented on MSHARED-750:


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_r205876862
 
 

 ##
 File path: 
src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
 ##
 @@ -99,27 +100,38 @@ public void testTranslateCommandline()
 assertCmdLineArgs( new String[] { "foo", " ' ", "bar" }, "foo \" ' \" 
bar" );
 }
 
-@Test
-public void 
givenASingleQuoteMarkInArgument_whenExecutingCode_thenExitCode0Returned() 
throws Exception {
-final Process p = exec("echo \"let's go\"");
 
-assertEquals(0, p.exitValue());
+@Test
+public void 
givenASingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkIsNotEscaped()
 throws Exception
+{
+final String command = "echo \"let's go\"";
+final String[] expected = new String[]{"echo", "let's go"};
+assertCmdLineArgs(expected, command);
 }
 
 @Test
-public void 
givenADoubleQuoteMarkInArgument_whenExecutingCode_thenExitCode0Returned() 
throws Exception {
-final Process p = exec("echo \"let\"s go\"");
+public void 
givenAnEscapedDoubleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
 throws Exception
+{
+final String command = "echo \"let\\\"s go\"";
+final String[] expected = new String[]{"echo", "let\\\"s go"};
+assertCmdLineArgs(expected, command);
+}
 
-assertEquals(0, p.exitValue());
+@Test
+public void 
givenAnEscapedSingleQuoteMarkInArgument_whenTranslatingToCmdLineArgs_thenTheQuotationMarkRemainsEscaped()
 throws Exception
+{
+final String command = "echo \"let\\\'s go\"";
+final String[] expected = new String[]{"echo", "let\\\'s go"};
+assertCmdLineArgs(expected, command);
 }
 
-private Process exec(String cmd) throws CommandLineException, 
InterruptedException {
 
 Review comment:
   Removed these tests as they seemed to always return 0, even when the 
exception was thrown.  However, they might be useful because they run on the 
system rather than just testing the setup?


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to [MSHARED_749], the following test will error (due to an exception 
> being thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (MSHARED-750) Unbalanced quotes in command with escaped double quotation mark

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/MSHARED-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16560171#comment-16560171
 ] 

ASF GitHub Bot commented on MSHARED-750:


KathrynN opened a new pull request #4: [MSHARED-750] - Unbalanced quotes in 
command with escaped double quot…
URL: https://github.com/apache/maven-shared-utils/pull/4
 
 
   …ation mark
   
   


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:
us...@infra.apache.org


> Unbalanced quotes in command with escaped double quotation mark
> ---
>
> Key: MSHARED-750
> URL: https://issues.apache.org/jira/browse/MSHARED-750
> Project: Maven Shared Components
>  Issue Type: Bug
>Reporter: Kathryn Newbould
>Priority: Major
>
> Due to [MSHARED_749], the following test will error (due to an exception 
> being thrown) in master maven:
> {code:java}
> @Test
> public void 
> givenAnEscapedDoubleQuoteMarkInArgument_whenPreparingToExecuteCode_thenTheQuotationMarkRemainsEscaped()
>  throws Exception {
> final String command = "echo \"let\\\"s go\"";
> final String[] actual = CommandLineUtils.translateCommandline(command);
> final String[] expected = new String[]{"echo", "let\\\"s go"};
> assertArrayEquals(expected, actual);
> }
> {code}
> Results:
> {code:java}
> org.apache.maven.shared.utils.cli.CommandLineException: unbalanced quotes in 
> echo "let\"s go"{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)