Merge pull request #7648 from lafirest/fix/remove_empty_check_in_fram_5
fix(frame): remove empty topic check, because it checked in emqx_channel
This commit is contained in:
commit
0d1b4969bf
|
@ -310,7 +310,6 @@ parse_packet(
|
|||
(PacketId =/= undefined) andalso
|
||||
StrictMode andalso validate_packet_id(PacketId),
|
||||
{Properties, Payload} = parse_properties(Rest1, Ver, StrictMode),
|
||||
ok = ensure_topic_name_valid(StrictMode, TopicName, Properties),
|
||||
Publish = #mqtt_packet_publish{
|
||||
topic_name = TopicName,
|
||||
packet_id = PacketId,
|
||||
|
@ -425,7 +424,6 @@ parse_will_message(
|
|||
{Props, Rest} = parse_properties(Bin, Ver, StrictMode),
|
||||
{Topic, Rest1} = parse_utf8_string(Rest, StrictMode),
|
||||
{Payload, Rest2} = parse_binary_data(Rest1),
|
||||
ok = ensure_topic_name_valid(StrictMode, Topic, Props),
|
||||
{
|
||||
Packet#mqtt_packet_connect{
|
||||
will_props = Props,
|
||||
|
@ -623,15 +621,6 @@ parse_binary_data(Bin) when
|
|||
->
|
||||
?PARSE_ERR(malformed_binary_data_length).
|
||||
|
||||
ensure_topic_name_valid(false, _TopicName, _Properties) ->
|
||||
ok;
|
||||
ensure_topic_name_valid(true, TopicName, _Properties) when TopicName =/= <<>> ->
|
||||
ok;
|
||||
ensure_topic_name_valid(true, <<>>, #{'Topic-Alias' := _}) ->
|
||||
ok;
|
||||
ensure_topic_name_valid(true, <<>>, _) ->
|
||||
error(empty_topic_name).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% Serialize MQTT Packet
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -157,17 +157,6 @@ t_parse_malformed_utf8_string(_) ->
|
|||
ParseState = emqx_frame:initial_parse_state(#{strict_mode => true}),
|
||||
?ASSERT_FRAME_THROW(utf8_string_invalid, emqx_frame:parse(MalformedPacket, ParseState)).
|
||||
|
||||
t_parse_empty_topic_name(_) ->
|
||||
Packet = ?PUBLISH_PACKET(?QOS_1, <<>>, 1, #{}, <<>>),
|
||||
?assertEqual(Packet, parse_serialize(Packet, #{strict_mode => false})),
|
||||
?ASSERT_FRAME_THROW(empty_topic_name, parse_serialize(Packet, #{strict_mode => true})).
|
||||
|
||||
t_parse_empty_topic_name_with_alias(_) ->
|
||||
Props = #{'Topic-Alias' => 16#AB},
|
||||
Packet = ?PUBLISH_PACKET(?QOS_1, <<>>, 1, Props, <<>>),
|
||||
?assertEqual(Packet, parse_serialize(Packet, #{strict_mode => false})),
|
||||
?assertEqual(Packet, parse_serialize(Packet, #{strict_mode => true})).
|
||||
|
||||
t_serialize_parse_v3_connect(_) ->
|
||||
Bin =
|
||||
<<16, 37, 0, 6, 77, 81, 73, 115, 100, 112, 3, 2, 0, 60, 0, 23, 109, 111, 115, 113, 112, 117,
|
||||
|
|
Loading…
Reference in New Issue