From da31ff9fdab9383e7d4a8fe40a9598a4d5d4ecf5 Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Wed, 17 Jul 2024 18:54:55 -0300 Subject: [PATCH] fix: unescape attribute values (#3939) * fix: unescape attribute values * simplify test --- server/expression/executor.go | 3 ++- server/expression/executor_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/expression/executor.go b/server/expression/executor.go index 8874178b55..36edd730c3 100644 --- a/server/expression/executor.go +++ b/server/expression/executor.go @@ -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) { diff --git a/server/expression/executor_test.go b/server/expression/executor_test.go index f78247ade4..7fdb0c00fc 100644 --- a/server/expression/executor_test.go +++ b/server/expression/executor_test.go @@ -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)