You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hierarchical topics are not handled correctly. More concretely, if I subscribe to a topic at a high level in the hierarchy I will also receive messages published at a lower level.
I tested the following simple example:
Connect with Client C1 and receive ConnAck
Subscribe with C1 to topic "my_topic" and receive SubAck
Publish message "my_message" with C1 and QoS 1 to "my_topic/other_topic" and receive PubAck and additionally a Publish-message for "my_topic/other_topic" with message "my_message"
Thus, the subscription to "my_topic" works like a subscription to "my_topic/#". I would interpret this as a violation of the MQTT-standard and I also checked with emqtt and mosquitto, which would not send a Publish in response to the last step.
A quick fix would be to change Line 623 from match_pattern = re.compile(a_filter.replace('#', '.*').replace('$', '\$').replace('+', '[/\$\s\w\d]+'))
to match_pattern = re.compile("^"+a_filter.replace('#', '.*').replace('$', '\$').replace('+', '[/\$\s\w\d]+')+"$")
However, I am neither a Python-expert nor did I test the fix thoroughly.
The text was updated successfully, but these errors were encountered:
I do not know whether I should open another issue as this is kind of related, but I will do so if necessary. There is another problem, which existed before and persists with the fix committed yesterday. The single-level wildcards denoted by + should not match more than one level, but the replacement-regex allows matching strings as well as level-separators /, so I guess replace('+', '[/\$\s\w\d]+') should be changed to something like replace('+', '[^/\$\s\w\d]+'), i.e. it should only match characters unequal to a /.
I should note that I did not evaluate this fix thoroughly either. I just checked with some string and did not test special cases like zero length topic names.
However, by doing so, the issue raised yesterday would still persist I think. Since the regex would partially match, by subscribing to a/+/b, one would also receive messages published for a/something/b/anotherthing.
Hierarchical topics are not handled correctly. More concretely, if I subscribe to a topic at a high level in the hierarchy I will also receive messages published at a lower level.
I tested the following simple example:
ConnAck
SubAck
"my_message"
with C1 and QoS 1 to"my_topic/other_topic"
and receivePubAck
and additionally aPublish
-message for"my_topic/other_topic"
with message"my_message"
Thus, the subscription to
"my_topic"
works like a subscription to"my_topic/#"
. I would interpret this as a violation of the MQTT-standard and I also checked with emqtt and mosquitto, which would not send aPublish
in response to the last step.A quick fix would be to change Line 623 from
match_pattern = re.compile(a_filter.replace('#', '.*').replace('$', '\$').replace('+', '[/\$\s\w\d]+'))
to
match_pattern = re.compile("^"+a_filter.replace('#', '.*').replace('$', '\$').replace('+', '[/\$\s\w\d]+')+"$")
However, I am neither a Python-expert nor did I test the fix thoroughly.
The text was updated successfully, but these errors were encountered: