Commit 0ca274282ab97f04a93f9e7d8729d58fa48723da
1 parent
460ff3ed
Fix valid subscribe path check
Showing
2 changed files
with
2 additions
and
1 deletions
FlashMQTests/tst_maintests.cpp
| @@ -308,6 +308,7 @@ void MainTests::test_validSubscribePath() | @@ -308,6 +308,7 @@ void MainTests::test_validSubscribePath() | ||
| 308 | QVERIFY(isValidSubscribePath("//#")); | 308 | QVERIFY(isValidSubscribePath("//#")); |
| 309 | QVERIFY(isValidSubscribePath("+")); | 309 | QVERIFY(isValidSubscribePath("+")); |
| 310 | QVERIFY(isValidSubscribePath("")); | 310 | QVERIFY(isValidSubscribePath("")); |
| 311 | + QVERIFY(isValidSubscribePath("hello")); | ||
| 311 | 312 | ||
| 312 | QVERIFY(!isValidSubscribePath("one/tw+o/three")); | 313 | QVERIFY(!isValidSubscribePath("one/tw+o/three")); |
| 313 | QVERIFY(!isValidSubscribePath("one/+o/three")); | 314 | QVERIFY(!isValidSubscribePath("one/+o/three")); |
mqttpacket.cpp
| @@ -375,7 +375,7 @@ void MqttPacket::handleSubscribe() | @@ -375,7 +375,7 @@ void MqttPacket::handleSubscribe() | ||
| 375 | if (topic.empty() || !isValidUtf8(topic)) | 375 | if (topic.empty() || !isValidUtf8(topic)) |
| 376 | throw ProtocolError("Subscribe topic not valid UTF-8."); | 376 | throw ProtocolError("Subscribe topic not valid UTF-8."); |
| 377 | 377 | ||
| 378 | - if (isValidSubscribePath(topic)) | 378 | + if (!isValidSubscribePath(topic)) |
| 379 | throw ProtocolError(formatString("Invalid subscribe path: %s", topic.c_str())); | 379 | throw ProtocolError(formatString("Invalid subscribe path: %s", topic.c_str())); |
| 380 | 380 | ||
| 381 | char qos = readByte(); | 381 | char qos = readByte(); |