Merge pull request #13860 from rabbitmq/mergify/bp/v4.1.x/pr-13858
Test (make) / Build and Xref (1.17, 26) (push) Has been cancelled Details
Test (make) / Build and Xref (1.17, 27) (push) Has been cancelled Details
Test (make) / Test (1.17, 26, khepri) (push) Has been cancelled Details
Test (make) / Test (1.17, 26, mnesia) (push) Has been cancelled Details
Test (make) / Test mixed clusters (1.17, 26, khepri) (push) Has been cancelled Details
Test (make) / Test mixed clusters (1.17, 26, mnesia) (push) Has been cancelled Details
Test (make) / Type check (1.17, 27) (push) Has been cancelled Details

STOMP: confirm utf-8 handling (backport #13858)
(cherry picked from commit 0aeca40416)
This commit is contained in:
Michael Klishin 2025-05-06 18:53:14 +04:00 committed by Michael Klishin
parent 6fe6410fd5
commit ebc0bbb634
No known key found for this signature in database
GPG Key ID: 16AB14D00D613900
2 changed files with 24 additions and 3 deletions

View File

@ -92,13 +92,13 @@ parse_resume_mid_command(_) ->
{ok, #stomp_frame{command = "COMMAND"}, _Rest} = parse(Second, Resume).
parse_resume_mid_header_key(_) ->
First = "COMMAND\nheade",
First = "COMMAND\nhead",
Second = "r1:value1\n\n\0",
{more, Resume} = parse(First),
{ok, Frame = #stomp_frame{command = "COMMAND"}, _Rest} =
parse(Second, Resume),
?assertEqual({ok, "value1"},
rabbit_stomp_frame:header(Frame, "header1")).
rabbit_stomp_frame:header(Frame, binary_to_list(<<"headꙕr1"/utf8>>))).
parse_resume_mid_header_val(_) ->
First = "COMMAND\nheader1:val",
@ -215,7 +215,7 @@ headers_escaping_roundtrip_without_trailing_lf(_) ->
parse(Content) ->
parse(Content, rabbit_stomp_frame:initial_state()).
parse(Content, State) ->
rabbit_stomp_frame:parse(list_to_binary(Content), State).
rabbit_stomp_frame:parse(unicode:characters_to_binary(Content), State).
parse_complete(Content) ->
{ok, Frame = #stomp_frame{command = Command}, State} = parse(Content),

View File

@ -119,6 +119,27 @@ class TestParsing(unittest.TestCase):
'hello\n\0')
self.match(resp, self.cd.recv(4096).decode('utf-8'))
@connect(['cd'])
def test_unicode(self):
cmd = ('\n'
'SUBSCRIBE\n'
'destination:/exchange/amq.fanout\n'
'\n\x00\n'
'SEND\n'
'destination:/exchange/amq.fanout\n'
'headꙕr1:valꙕe1\n\n'
'hello\n\x00')
self.cd.sendall(cmd.encode('utf-8'))
resp = ('MESSAGE\n'
'destination:/exchange/amq.fanout\n'
'message-id:Q_/exchange/amq.fanout@@session-(.*)\n'
'redelivered:false\n'
'headꙕr1:valꙕe1\n'
'content-length:6\n'
'\n'
'hello\n\0')
self.match(resp, self.cd.recv(4096).decode('utf-8'))
@connect(['cd'])
def test_send_without_content_type_binary(self):
msg = 'hello'