-
Notifications
You must be signed in to change notification settings - Fork 51
Incorrect remaining length is calculated when topic contains utf-8-3 or utf-8-4 characters in SUBSCRIBE/PUBLISH packets #90
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
Comments
@Eason010212 Hi - are you interested in submitting this as a pull request? I'll review it. |
|
FoamyGuy
added a commit
that referenced
this issue
Dec 22, 2021
Fix Issue #90: Remaining length issues
closed by #91 |
rtwfroody
pushed a commit
to rtwfroody/Adafruit_CircuitPython_MiniMQTT
that referenced
this issue
Sep 18, 2022
Fix Issue adafruit#90: Remaining length issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current version of adafruit_minimqtt.py uses len() method to calculate a packet's remaining length, for example:
Adafruit_CircuitPython_MiniMQTT/adafruit_minimqtt/adafruit_minimqtt.py
Line 671 in c55a484
Adafruit_CircuitPython_MiniMQTT/adafruit_minimqtt/adafruit_minimqtt.py
Line 592 in c55a484
As shown above, strings are measured instead of UTF-8 bytes. When a topic only contains English characters, numbers and punctuation marks, the calculation result is correct; However, when it contains some utf-8-3 or utf-8-4 characters (such as Chinese characters) , an incorrect calculation result of remaining length will be obtained. For example, the actual encoding length of "中文" should be 6, while the length calculated by len() is 2. As a result, such packets will be rejected by any MQTT server.
In MQTT protocol, there is no restriction on utf-8-3 or utf-8-4 characters, so I think this issue is probably a bug that needs to be fixed.
At present, in the application I developed, I rewrite the len() method to temporarily solve this problem, but I still hope that the developers of this library can make official bug fixes.
Thank you very much.
The text was updated successfully, but these errors were encountered: