Skip to content

Fix TopicUtil accepting shared subscription with empty filter - #317

Open
pallavithegod wants to merge 1 commit into
apache:mainfrom
pallavithegod:fix-share-empty-filter-288
Open

pallavithegod wants to merge 1 commit into
apache:mainfrom
pallavithegod:fix-share-empty-filter-288

Conversation

@pallavithegod

Copy link
Copy Markdown

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.

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
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

1 participant