Merge pull request #4416 from node-red/mqtt-check-topic-length

check topic length > 0 before publish
pull/4417/head^2
Nick O'Leary 2023-11-07 17:46:33 +00:00 committed by GitHub
commit c6a8eee73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

View File

@ -104,6 +104,7 @@ module.exports = function(RED) {
* @returns `true` if it is a valid topic
*/
function isValidPublishTopic(topic) {
if (topic.length === 0) return false;
return !/[\+#\b\f\n\r\t\v\0]/.test(topic);
}