-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
etcdctl: fix quotes in txn and watch #6325
etcdctl: fix quotes in txn and watch #6325
Conversation
rqs := []txnRequests{ | ||
txnRequests{ | ||
compare: []string{`version("key1") = "1"`, `version("key2") = "1"`}, | ||
ifSucess: []string{"get key1", "get key2", `put "key \"with\" space" "value \x23"`}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this should fail without this patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the regex was completely broken
18ff804
to
fc90fa9
Compare
@@ -48,8 +48,23 @@ func addHexPrefix(s string) string { | |||
} | |||
|
|||
func argify(s string) []string { | |||
r := regexp.MustCompile("'.+'|\".+\"|\\S+") | |||
return r.FindAllString(s, -1) | |||
r := regexp.MustCompile(`"(\\.|[^"])*"|'[^']*'|[^'"\s]\S*[^'"\s]?`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the single quote and non-quote one looks fine to me.
It seems like people use /"(?:[^"\\]|\\.)*"/
for double quote to deal with backslash.
See http://stackoverflow.com/questions/249791/regex-for-quoted-string-with-escaping-quotes.
Not sure if it necessary for us though, since we will do scanf %q later.
lgtm |
fc90fa9
to
666e7bd
Compare
Fixes #6315