Browse Source

Alter behaviour of CommandUtils wrt stripping spaces

Change-Id: I9a785f381e5e9ad6eea80c7ff69e6319565c21ad
Reviewed-on: http://gerrit.dmdirc.com/2443
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 12 years ago
parent
commit
ccfd2a635c

+ 0
- 2
src/com/dmdirc/util/CommandUtils.java View File

54
                 builder.delete(0, builder.length());
54
                 builder.delete(0, builder.length());
55
                 inquote = false;
55
                 inquote = false;
56
             } else if (inquote) {
56
             } else if (inquote) {
57
-                if (builder.length() > 0) {
58
                     builder.append(' ');
57
                     builder.append(' ');
59
-                }
60
 
58
 
61
                 builder.append(word);
59
                 builder.append(word);
62
             } else if (word.startsWith("\"") && !word.endsWith("\"")) {
60
             } else if (word.startsWith("\"") && !word.endsWith("\"")) {

+ 3
- 1
test/com/dmdirc/util/CommandUtilsTest.java View File

24
 import java.util.Arrays;
24
 import java.util.Arrays;
25
 
25
 
26
 import org.junit.Test;
26
 import org.junit.Test;
27
+
27
 import static org.junit.Assert.*;
28
 import static org.junit.Assert.*;
28
 
29
 
29
 public class CommandUtilsTest {
30
 public class CommandUtilsTest {
31
+
30
     @Test
32
     @Test
31
     public void testParseArguments() {
33
     public void testParseArguments() {
32
         final String[][][] tests = new String[][][]{
34
         final String[][][] tests = new String[][][]{
36
             {{"abcdef \"abcdef\" \"abcdef\""}, {"abcdef", "abcdef", "abcdef"}},
38
             {{"abcdef \"abcdef\" \"abcdef\""}, {"abcdef", "abcdef", "abcdef"}},
37
             {{"abcdef \"\""}, {"abcdef", ""}},
39
             {{"abcdef \"\""}, {"abcdef", ""}},
38
             {{"abcdef \" foo?\""}, {"abcdef", " foo?"}},
40
             {{"abcdef \" foo?\""}, {"abcdef", " foo?"}},
39
-        };
41
+            {{"abcdef \" foo? bar\""}, {"abcdef", " foo? bar"}},};
40
 
42
 
41
         for (String[][] test : tests) {
43
         for (String[][] test : tests) {
42
             final String[] res = CommandUtils.parseArguments(test[0][0]);
44
             final String[] res = CommandUtils.parseArguments(test[0][0]);

Loading…
Cancel
Save