Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
af7ede6e
Unverified
Commit
af7ede6e
authored
Feb 19, 2018
by
Carl Bergquist
Committed by
GitHub
Feb 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10959 from grafana/10957_influx_escaping
influxdb: escape backslashes in tag values (for alerting)
parents
0b8c3ab5
f959ba9b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletions
+7
-1
pkg/tsdb/influxdb/query.go
+1
-1
pkg/tsdb/influxdb/query_test.go
+6
-0
No files found.
pkg/tsdb/influxdb/query.go
View file @
af7ede6e
...
...
@@ -70,7 +70,7 @@ func (query *Query) renderTags() []string {
}
else
if
tag
.
Operator
==
"<"
||
tag
.
Operator
==
">"
{
textValue
=
tag
.
Value
}
else
{
textValue
=
fmt
.
Sprintf
(
"'%s'"
,
tag
.
Value
)
textValue
=
fmt
.
Sprintf
(
"'%s'"
,
strings
.
Replace
(
tag
.
Value
,
`\`
,
`\\`
,
-
1
)
)
}
res
=
append
(
res
,
fmt
.
Sprintf
(
`%s"%s" %s %s`
,
str
,
tag
.
Key
,
tag
.
Operator
,
textValue
))
...
...
pkg/tsdb/influxdb/query_test.go
View file @
af7ede6e
...
...
@@ -170,6 +170,12 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
So
(
strings
.
Join
(
query
.
renderTags
(),
""
),
ShouldEqual
,
`"key" = 'value'`
)
})
Convey
(
"can escape backslashes when rendering string tags"
,
func
()
{
query
:=
&
Query
{
Tags
:
[]
*
Tag
{{
Operator
:
"="
,
Value
:
`C:\test\`
,
Key
:
"key"
}}}
So
(
strings
.
Join
(
query
.
renderTags
(),
""
),
ShouldEqual
,
`"key" = 'C:\\test\\'`
)
})
Convey
(
"can render regular measurement"
,
func
()
{
query
:=
&
Query
{
Measurement
:
`apa`
,
Policy
:
"policy"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment