Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mqtt topic filtering does not conform to spec: filter foo/+/bar/# won't catch messages published to foo/something/bar #918

Open
3 tasks
marco-kaeferbeck opened this issue Apr 4, 2022 · 1 comment

Comments

@marco-kaeferbeck
Copy link
Contributor

marco-kaeferbeck commented Apr 4, 2022

In the case that there is a single level wildcard somewhere in the topic the fixes provided by #418 won't work

For example when i subscribe to foo/+/bar/# and publish on foo/something/bar

-> if (topicName.charAt(topicPos - 1) == '/' && topicFilter.charAt(filterPos) == '#')
this returns false, because the topicFilter at filterPos is / and not #

-> if (topicFilter.length() - filterPos > 1 && topicFilter.substring(filterPos, filterPos + 2).equals("/#"))
returns false, because topicFilter length - filterPos is exactly 1

-> if ((topicFilter.length() - topicName.length()) == 2 && topicFilter.substring(topicFilter.length() - 2, topicFilter.length()).equals("/#"))
returns false, because topicFilter length - topicName length is negative the length of the word that replaces the single level wildcard plus 3 ( 1 for the single level wildcard and 2 for the /#)

  • Bug exists Release Version 1.2.5 ( Master Branch)
  • Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
  • Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
@czulehner
Copy link

Added another test at org.eclipse.paho.mqttv5.common.utils.MqttTopicTest.testMatchedTopicFilterWildcards()

{ "sport/tennis/+/ranking/#", "sport/tennis/player1/ranking"} fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants