Skip to content

Commit 0aeca40

Browse files
Merge pull request #13860 from rabbitmq/mergify/bp/v4.1.x/pr-13858
STOMP: confirm utf-8 handling (backport #13858)
2 parents 1b7d668 + 0d284b0 commit 0aeca40

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

deps/rabbitmq_stomp/test/frame_SUITE.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ parse_resume_mid_command(_) ->
9292
{ok, #stomp_frame{command = "COMMAND"}, _Rest} = parse(Second, Resume).
9393

9494
parse_resume_mid_header_key(_) ->
95-
First = "COMMAND\nheade",
95+
First = "COMMAND\nheadꙕ",
9696
Second = "r1:value1\n\n\0",
9797
{more, Resume} = parse(First),
9898
{ok, Frame = #stomp_frame{command = "COMMAND"}, _Rest} =
9999
parse(Second, Resume),
100100
?assertEqual({ok, "value1"},
101-
rabbit_stomp_frame:header(Frame, "header1")).
101+
rabbit_stomp_frame:header(Frame, binary_to_list(<<"headꙕr1"/utf8>>))).
102102

103103
parse_resume_mid_header_val(_) ->
104104
First = "COMMAND\nheader1:val",
@@ -215,7 +215,7 @@ headers_escaping_roundtrip_without_trailing_lf(_) ->
215215
parse(Content) ->
216216
parse(Content, rabbit_stomp_frame:initial_state()).
217217
parse(Content, State) ->
218-
rabbit_stomp_frame:parse(list_to_binary(Content), State).
218+
rabbit_stomp_frame:parse(unicode:characters_to_binary(Content), State).
219219

220220
parse_complete(Content) ->
221221
{ok, Frame = #stomp_frame{command = Command}, State} = parse(Content),

deps/rabbitmq_stomp/test/python_SUITE_data/src/parsing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ def test_send_without_content_type(self):
119119
'hello\n\0')
120120
self.match(resp, self.cd.recv(4096).decode('utf-8'))
121121

122+
@connect(['cd'])
123+
def test_unicode(self):
124+
cmd = ('\n'
125+
'SUBSCRIBE\n'
126+
'destination:/exchange/amq.fanout\n'
127+
'\n\x00\n'
128+
'SEND\n'
129+
'destination:/exchange/amq.fanout\n'
130+
'headꙕr1:valꙕe1\n\n'
131+
'hello\n\x00')
132+
self.cd.sendall(cmd.encode('utf-8'))
133+
resp = ('MESSAGE\n'
134+
'destination:/exchange/amq.fanout\n'
135+
'message-id:Q_/exchange/amq.fanout@@session-(.*)\n'
136+
'redelivered:false\n'
137+
'headꙕr1:valꙕe1\n'
138+
'content-length:6\n'
139+
'\n'
140+
'hello\n\0')
141+
self.match(resp, self.cd.recv(4096).decode('utf-8'))
142+
122143
@connect(['cd'])
123144
def test_send_without_content_type_binary(self):
124145
msg = 'hello'

0 commit comments

Comments
 (0)