Skip to content
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

Merged
merged 2 commits into from
Sep 2, 2016

Conversation

heyitsanthony
Copy link
Contributor

Fixes #6315

rqs := []txnRequests{
txnRequests{
compare: []string{`version("key1") = "1"`, `version("key2") = "1"`},
ifSucess: []string{"get key1", "get key2", `put "key \"with\" space" "value \x23"`},
Copy link
Contributor

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?

Copy link
Contributor Author

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

@@ -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]?`)
Copy link
Contributor

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.

@xiang90
Copy link
Contributor

xiang90 commented Sep 2, 2016

lgtm

@heyitsanthony heyitsanthony merged commit e93ee61 into etcd-io:master Sep 2, 2016
@heyitsanthony heyitsanthony deleted the etcdctl-txn-quotes branch September 6, 2016 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants