rumqtt icon indicating copy to clipboard operation
rumqtt copied to clipboard

Empty strings are considered as valid topic

Open ThejasKiranPS opened this issue 2 years ago • 3 comments

Expected Behavior

Publishing or Subscribing to an empty-string-topic should throw an error.

Current Behavior

Allows the usage of empty string as topic.

References

Topic semantic and usage

There is also a size limit and a null-character rule which I think is also not checked for.

ThejasKiranPS avatar Mar 26 '23 18:03 ThejasKiranPS

We could create a Topic struct which runs all these checks when a new topic is being created (Topic::new(&str))

or manually check with fn valid_topic() everywhere. Is there a better way to do this?

ThejasKiranPS avatar Mar 26 '23 18:03 ThejasKiranPS

We could create a Topic struct which runs all these checks when a new topic is being created (Topic::new(&str))

or manually check with fn valid_topic() everywhere. Is there a better way to do this?

The use of a Topic type which handles validation at construction only is the way to go, IMO!

AlexandreCassagne avatar Mar 05 '24 19:03 AlexandreCassagne

The use of a Topic type which handles validation at construction only is the way to go, IMO!

agree, but topic/filter needs to be validated only once!

in rumqttc, when we call publish / subscribe. in rumqttd, when publish/subscribe packet is received and being handled.

So we have to think on pros/cons of using Topic. also, we just need to add some more checks like length and null byte in validate_topic fn and this should resolve the issue as well right?

swanandx avatar Mar 06 '24 07:03 swanandx