Skip to content

Commit 8343e98

Browse files
authored
fix(internal): allow tagset values to contain equal signs (#3204)
Revision to the original spec to allow equal signs in tag values to accommodate base64 encoded values.
1 parent ab87f30 commit 8343e98

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

ddtrace/internal/_tagset.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Tagset eBNF::
33
44
tagset = tag, { ",", tag };
5-
tag = ( identifier - space ), "=", identifier;
6-
identifier = { ? ASCII 32-126 ? - equal or comma };
5+
tag = key, "=", value;
6+
key = { ? ASCII 32-126 ? - equal or comma or space };
7+
value = { ? ASCII 32-126 ? - comma };
78
equal or comma = "=" | ",";
89
space = " ";
910
"""
@@ -64,10 +65,9 @@ cdef inline int is_valid_key_char(int c):
6465

6566
# Same as is_valid_key_char except spaces are allowed
6667
cdef inline int is_valid_value_char(int c):
67-
# string.printable - ",="
68+
# string.printable - ","
6869
# 44 = ",""
69-
# 61 = "="
70-
return c == 32 or is_valid_key_char(c)
70+
return c == 32 or is_equal(c) or is_valid_key_char(c)
7171

7272

7373
cpdef dict decode_tagset_string(str tagset):

tests/tracer/test_tagset.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
("key=value,", {"key": "value"}),
3030
# Values can have spaces
3131
("key=value can have spaces", {"key": "value can have spaces"}),
32+
# Values can have equals
33+
("key=value=value", {"key": "value=value"}),
3234
# Remove leading/trailing spaces from values
3335
("key= value can have spaces ", {"key": "value can have spaces"}),
3436
# Non-space whitespace characters are allowed
@@ -41,6 +43,13 @@
4143
"_dd.p.upstream_services=bWNudWx0eS13ZWI|0|1;dHJhY2Utc3RhdHMtcXVlcnk|2|4,_dd.p.hello=world",
4244
{"_dd.p.upstream_services": "bWNudWx0eS13ZWI|0|1;dHJhY2Utc3RhdHMtcXVlcnk|2|4", "_dd.p.hello": "world"},
4345
),
46+
(
47+
"_dd.p.upstream_services=bWNudWx0eS13ZWI===|0|1;dHJhY2Utc3RhdHMtcXVlcnk===|2|4,_dd.p.hello=world",
48+
{
49+
"_dd.p.upstream_services": "bWNudWx0eS13ZWI===|0|1;dHJhY2Utc3RhdHMtcXVlcnk===|2|4",
50+
"_dd.p.hello": "world",
51+
},
52+
),
4453
],
4554
)
4655
def test_decode_tagset_string(header, expected):
@@ -61,7 +70,6 @@ def test_decode_tagset_string(header, expected):
6170
"=value",
6271
# Extra leading comma
6372
",key=value",
64-
"key=value=value",
6573
"key=value,=value",
6674
"key=value,value",
6775
# Spaces are not allowed in keys

0 commit comments

Comments
 (0)