Merge pull request #11074 from JimMoen/fix-share-sub-nl-protocol-error
fix: shared-sub with nl sub-option should cause protocol error
This commit is contained in:
commit
30ac6c4e48
|
@ -270,6 +270,9 @@ check(#mqtt_packet_subscribe{topic_filters = TopicFilters}) ->
|
|||
try
|
||||
validate_topic_filters(TopicFilters)
|
||||
catch
|
||||
%% Known Specificed Reason Code
|
||||
error:{error, RC} ->
|
||||
{error, RC};
|
||||
error:_Error ->
|
||||
{error, ?RC_TOPIC_FILTER_INVALID}
|
||||
end;
|
||||
|
@ -413,6 +416,10 @@ run_checks([Check | More], Packet, Options) ->
|
|||
validate_topic_filters(TopicFilters) ->
|
||||
lists:foreach(
|
||||
fun
|
||||
%% Protocol Error and Should Disconnect
|
||||
%% MQTT-5.0 [MQTT-3.8.3-4] and [MQTT-4.13.1-1]
|
||||
({<<?SHARE, "/", _Rest/binary>>, #{nl := 1}}) ->
|
||||
error({error, ?RC_PROTOCOL_ERROR});
|
||||
({TopicFilter, _SubOpts}) ->
|
||||
emqx_topic:validate(TopicFilter);
|
||||
(TopicFilter) ->
|
||||
|
|
|
@ -985,3 +985,18 @@ t_shared_subscriptions_client_terminates_when_qos_eq_2(Config) ->
|
|||
|
||||
?assertEqual(1, counters:get(CRef, 1)),
|
||||
process_flag(trap_exit, false).
|
||||
|
||||
t_share_subscribe_no_local(Config) ->
|
||||
ConnFun = ?config(conn_fun, Config),
|
||||
process_flag(trap_exit, true),
|
||||
ShareTopic = <<"$share/sharename/TopicA">>,
|
||||
|
||||
{ok, Client} = emqtt:start_link([{proto_ver, v5} | Config]),
|
||||
{ok, _} = emqtt:ConnFun(Client),
|
||||
%% MQTT-5.0 [MQTT-3.8.3-4] and [MQTT-4.13.1-1] (Disconnect)
|
||||
case catch emqtt:subscribe(Client, #{}, [{ShareTopic, [{nl, true}, {qos, 1}]}]) of
|
||||
{'EXIT', {Reason, _Stk}} ->
|
||||
?assertEqual({disconnected, ?RC_PROTOCOL_ERROR, #{}}, Reason)
|
||||
end,
|
||||
|
||||
process_flag(trap_exit, false).
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix to adhere to Protocol spec MQTT-5.0 [MQTT-3.8.3-4].
|
Loading…
Reference in New Issue