-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix string field value escaping #3088
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,7 +453,7 @@ func TestParsePointWithStringWithCommas(t *testing.T) { | |
}, | ||
Fields{ | ||
"value": 1.0, | ||
"str": "foo,bar", // commas in string value | ||
"str": `foo\,bar`, // commas in string value | ||
}, | ||
time.Unix(1, 0)), | ||
) | ||
|
@@ -475,6 +475,37 @@ func TestParsePointWithStringWithCommas(t *testing.T) { | |
|
||
} | ||
|
||
func TestParsePointEscapedStringsAndCommas(t *testing.T) { | ||
// non-escaped comma and quotes | ||
test(t, `cpu,host=serverA,region=us-east value="{Hello\"{,}\" World}" 1000000000`, | ||
NewPoint( | ||
"cpu", | ||
Tags{ | ||
"host": "serverA", | ||
"region": "us-east", | ||
}, | ||
Fields{ | ||
"value": `{Hello"{,}" World}`, | ||
}, | ||
time.Unix(1, 0)), | ||
) | ||
|
||
// escaped comma and quotes | ||
test(t, `cpu,host=serverA,region=us-east value="{Hello\"{\,}\" World}" 1000000000`, | ||
NewPoint( | ||
"cpu", | ||
Tags{ | ||
"host": "serverA", | ||
"region": "us-east", | ||
}, | ||
Fields{ | ||
"value": `{Hello"{\,}" World}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the comma still preceded by a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
}, | ||
time.Unix(1, 0)), | ||
) | ||
|
||
} | ||
|
||
func TestParsePointWithStringWithEquals(t *testing.T) { | ||
test(t, `cpu,host=serverA,region=us-east str="foo=bar",value=1.0, 1000000000`, | ||
NewPoint( | ||
|
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.
If
i
is zero, this might blow up, right?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.
Technically, yes, if you call
scanFieldValue(buf, 0)
directly then it can blow up buti
can't be zero during parsing because we need to scan the the field name first and it must be non-zero in length so the function is always called with a non-zero value fori
. I could special case it here too but didn't think it was necessary since the func is private and only called in one place.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.
Cool on that reasoning -- thanks.
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.
Called here: https://github.com/influxdb/influxdb/blob/master/tsdb/points.go#L890