Vendor package update github.com/mattn/go-shellwords
| ... | ... |
@@ -10,7 +10,7 @@ github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://githu |
| 10 | 10 |
github.com/gorilla/context v1.1 |
| 11 | 11 |
github.com/gorilla/mux v1.1 |
| 12 | 12 |
github.com/kr/pty 5cf931ef8f |
| 13 |
-github.com/mattn/go-shellwords v1.0.0 |
|
| 13 |
+github.com/mattn/go-shellwords v1.0.3 |
|
| 14 | 14 |
github.com/tchap/go-patricia v2.2.6 |
| 15 | 15 |
github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 |
| 16 | 16 |
# forked golang.org/x/net package includes a patch for lazy loading trace templates |
| 17 | 17 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+The MIT License (MIT) |
|
| 1 |
+ |
|
| 2 |
+Copyright (c) 2017 Yasuhiro Matsumoto |
|
| 3 |
+ |
|
| 4 |
+Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 5 |
+of this software and associated documentation files (the "Software"), to deal |
|
| 6 |
+in the Software without restriction, including without limitation the rights |
|
| 7 |
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
| 8 |
+copies of the Software, and to permit persons to whom the Software is |
|
| 9 |
+furnished to do so, subject to the following conditions: |
|
| 10 |
+ |
|
| 11 |
+The above copyright notice and this permission notice shall be included in all |
|
| 12 |
+copies or substantial portions of the Software. |
|
| 13 |
+ |
|
| 14 |
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
| 15 |
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
| 16 |
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
| 17 |
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
| 18 |
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
| 19 |
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
| 20 |
+SOFTWARE. |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"errors" |
| 5 | 5 |
"os" |
| 6 | 6 |
"regexp" |
| 7 |
- "strings" |
|
| 8 | 7 |
) |
| 9 | 8 |
|
| 10 | 9 |
var ( |
| ... | ... |
@@ -35,21 +34,24 @@ func replaceEnv(s string) string {
|
| 35 | 35 |
type Parser struct {
|
| 36 | 36 |
ParseEnv bool |
| 37 | 37 |
ParseBacktick bool |
| 38 |
+ Position int |
|
| 38 | 39 |
} |
| 39 | 40 |
|
| 40 | 41 |
func NewParser() *Parser {
|
| 41 |
- return &Parser{ParseEnv, ParseBacktick}
|
|
| 42 |
+ return &Parser{ParseEnv, ParseBacktick, 0}
|
|
| 42 | 43 |
} |
| 43 | 44 |
|
| 44 | 45 |
func (p *Parser) Parse(line string) ([]string, error) {
|
| 45 |
- line = strings.TrimSpace(line) |
|
| 46 |
- |
|
| 47 | 46 |
args := []string{}
|
| 48 | 47 |
buf := "" |
| 49 | 48 |
var escaped, doubleQuoted, singleQuoted, backQuote bool |
| 50 | 49 |
backtick := "" |
| 51 | 50 |
|
| 52 |
- for _, r := range line {
|
|
| 51 |
+ pos := -1 |
|
| 52 |
+ got := false |
|
| 53 |
+ |
|
| 54 |
+loop: |
|
| 55 |
+ for i, r := range line {
|
|
| 53 | 56 |
if escaped {
|
| 54 | 57 |
buf += string(r) |
| 55 | 58 |
escaped = false |
| ... | ... |
@@ -69,12 +71,13 @@ func (p *Parser) Parse(line string) ([]string, error) {
|
| 69 | 69 |
if singleQuoted || doubleQuoted || backQuote {
|
| 70 | 70 |
buf += string(r) |
| 71 | 71 |
backtick += string(r) |
| 72 |
- } else if buf != "" {
|
|
| 72 |
+ } else if got {
|
|
| 73 | 73 |
if p.ParseEnv {
|
| 74 | 74 |
buf = replaceEnv(buf) |
| 75 | 75 |
} |
| 76 | 76 |
args = append(args, buf) |
| 77 | 77 |
buf = "" |
| 78 |
+ got = false |
|
| 78 | 79 |
} |
| 79 | 80 |
continue |
| 80 | 81 |
} |
| ... | ... |
@@ -107,15 +110,21 @@ func (p *Parser) Parse(line string) ([]string, error) {
|
| 107 | 107 |
singleQuoted = !singleQuoted |
| 108 | 108 |
continue |
| 109 | 109 |
} |
| 110 |
+ case ';', '&', '|', '<', '>': |
|
| 111 |
+ if !(escaped || singleQuoted || doubleQuoted || backQuote) {
|
|
| 112 |
+ pos = i |
|
| 113 |
+ break loop |
|
| 114 |
+ } |
|
| 110 | 115 |
} |
| 111 | 116 |
|
| 117 |
+ got = true |
|
| 112 | 118 |
buf += string(r) |
| 113 | 119 |
if backQuote {
|
| 114 | 120 |
backtick += string(r) |
| 115 | 121 |
} |
| 116 | 122 |
} |
| 117 | 123 |
|
| 118 |
- if buf != "" {
|
|
| 124 |
+ if got {
|
|
| 119 | 125 |
if p.ParseEnv {
|
| 120 | 126 |
buf = replaceEnv(buf) |
| 121 | 127 |
} |
| ... | ... |
@@ -126,6 +135,8 @@ func (p *Parser) Parse(line string) ([]string, error) {
|
| 126 | 126 |
return nil, errors.New("invalid command line string")
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 |
+ p.Position = pos |
|
| 130 |
+ |
|
| 129 | 131 |
return args, nil |
| 130 | 132 |
} |
| 131 | 133 |
|