forked from TrueCloudLab/frostfs-node
[#744] util/attributes: Support escaped symbols
To encode attributes with semicolon or slash, use backslash as escaped character. Example: User-Agent:NeoFS\/0.23 Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
c3e2738a46
commit
6527f9157c
2 changed files with 44 additions and 1 deletions
|
@ -57,4 +57,16 @@ func TestParseV2Attributes(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Len(t, attrs, 5)
|
||||
})
|
||||
|
||||
t.Run("escape characters", func(t *testing.T) {
|
||||
from := []string{
|
||||
`/K\:ey1:V\/alue\\/Ke\/y2:Va\:lue`,
|
||||
}
|
||||
attrs, err := attributes.ParseV2Attributes(from, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, attrs[0].Key(), `K:ey1`)
|
||||
require.Equal(t, attrs[0].Value(), `V/alue\`)
|
||||
require.Equal(t, attrs[1].Key(), `Ke/y2`)
|
||||
require.Equal(t, attrs[1].Value(), `Va:lue`)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue