Send DISCONNECT packet with reason code PROTOCOL_ERROR when topic is empty, add checks for topics
This commit is contained in:
parent
9029ee29d3
commit
42b3c9b4d6
|
@ -208,6 +208,9 @@ received(Packet = ?PACKET(Type), PState) ->
|
|||
true ->
|
||||
{Packet1, PState1} = preprocess_properties(Packet, PState),
|
||||
process_packet(Packet1, inc_stats(recv, Type, PState1));
|
||||
{'EXIT', {topic_filters_invalid, _Stacktrace}} ->
|
||||
deliver({disconnect, ?RC_PROTOCOL_ERROR}, PState),
|
||||
{error, topic_filters_invalid, PState};
|
||||
{'EXIT', {Reason, _Stacktrace}} ->
|
||||
deliver({disconnect, ?RC_MALFORMED_PACKET}, PState),
|
||||
{error, Reason, PState}
|
||||
|
|
|
@ -184,9 +184,16 @@ parse(Topic = <<"$share/", _/binary>>, #{share := _Group}) ->
|
|||
error({invalid_topic, Topic});
|
||||
parse(<<"$queue/", Topic1/binary>>, Options) ->
|
||||
parse(Topic1, maps:put(share, <<"$queue">>, Options));
|
||||
parse(<<"$share/", Topic1/binary>>, Options) ->
|
||||
[Group, Topic2] = binary:split(Topic1, <<"/">>),
|
||||
{Topic2, maps:put(share, Group, Options)};
|
||||
parse(Topic = <<"$share/", Topic1/binary>>, Options) ->
|
||||
case binary:split(Topic1, <<"/">>) of
|
||||
[<<>>] -> error({invalid_topic, Topic});
|
||||
[_] -> error({invalid_topic, Topic});
|
||||
[Group, Topic2] ->
|
||||
case binary:match(Group, [<<"/">>, <<"+">>, <<"#">>]) of
|
||||
nomatch -> error({invalid_topic, Topic});
|
||||
_ -> {Topic2, maps:put(share, Group, Options)}
|
||||
end
|
||||
end;
|
||||
parse(Topic, Options) ->
|
||||
{Topic, Options}.
|
||||
|
||||
|
|
Loading…
Reference in New Issue