Skip to content

Commit

Permalink
fix: unescape attribute values (#3939)
Browse files Browse the repository at this point in the history
* fix: unescape attribute values

* simplify test
  • Loading branch information
mathnogueira authored Jul 17, 2024
1 parent e634079 commit da31ff9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/expression/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ func (e Executor) resolveAttribute(attribute *Attribute) (value.Value, error) {
return value.Nil, resolutionError(err)
}

return value.NewFromString(attributeValue), nil
str := value.NewFromString(attributeValue)
return value.NewFromString(str.UnescappedString()), nil
}

func (e Executor) resolveEnvironment(environment *Environment) (value.Value, error) {
Expand Down
13 changes: 13 additions & 0 deletions server/expression/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ func TestBasicExpressionExecution(t *testing.T) {
Query: `'This should be workin\'' = "This should be workin'"`,
ShouldPass: true,
},
{
Name: "escaped_strings_must_be_equal_to_unescaped_strings_when_escaping_is_not_required",
Query: `attr:response = '"text \"quoted\" and another \"quote\"",'`,
ShouldPass: true,
AttributeDataStore: expression.AttributeDataStore{
Span: traces.Span{
ID: id.NewRandGenerator().SpanID(),
Attributes: traces.NewAttributes(map[string]string{
"response": `"text \"quoted\" and another \"quote\"",`,
}),
},
},
},
}

executeTestCases(t, testCases)
Expand Down

0 comments on commit da31ff9

Please sign in to comment.