validate empty topics

This commit is contained in:
Ery Lee 2015-01-14 23:57:17 +08:00
parent 525a104976
commit d1ac732b8c
1 changed files with 4 additions and 0 deletions

View File

@ -381,6 +381,10 @@ validate_packet(#mqtt_packet{ header = #mqtt_packet_header { type = ?UNSUBSCRIB
validate_packet(_Packet) ->
ok.
validate_topics(Type, []) when Type =:= subscribe orelse Type =:= unsubscribe ->
lager:error("Empty Topics!"),
{error, empty_topics};
validate_topics(Type, Topics) when Type =:= subscribe orelse Type =:= unsubscribe ->
ErrTopics = [Topic || #mqtt_topic{name=Topic, qos=Qos} <- Topics,
not (emqtt_topic:validate({Type, Topic}) and validate_qos(Qos))],