Skip to content

Fix TopicUtil accepting shared subscription with empty filter - #317

Merged
popduke merged 2 commits into
apache:mainfrom
pallavithegod:fix-share-empty-filter-288
Nov 3, 2026
Merged

popduke merged 2 commits into
apache:mainfrom
pallavithegod:fix-share-empty-filter-288

Conversation

@pallavithegod

Copy link
Copy Markdown
Contributor

Summary

Reject $share/g/ and $oshare/g/ where the filter part is empty.

Previously TopicUtil.isValidTopicFilter returned true for these inputs because after skipping the share-name separator, i was advanced to topicFilter.length() and the main scan loop was skipped entirely.

Fix

Add explicit empty-filter guard after skipping the separator, per MQTT-4.8.2-2.

Fixes #288

Verification

  • Updated TopicUtilsTest: $share/g/ now asserts false, added $oshare/g/ coverage. $share/g// remains true.
  • TopicUtilsTest: 7 tests run, 0 failures.

pallavithegod and others added 2 commits October 14, 2026 21:11
Reject \/g/ and \/g/ where the filter part is empty.
Previously isValidTopicFilter returned true because the scan loop
was skipped when i == length. Add explicit empty-filter guard
after skipping the share separator per MQTT-4.8.2-2.

Fixes apache#288
@popduke
popduke merged commit 6ef1d51 into apache:main Nov 3, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

[BUG] TopicUtil.isValidTopicFilter accepts "$share/g/" — a shared subscription with an empty filter that can never match

2 participants