diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html index ecef71366..b22b9545f 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html @@ -442,7 +442,17 @@ } return defaultContentType || 'none' } - + /** + * Test a topic string is valid for publishing + * @param {string} topic + * @returns `true` if it is a valid topic + */ + function validateMQTTPublishTopic(topic, opts) { + if(!topic || topic == "" || !/[\+#\b\f\n\r\t\v\0]/.test(topic)) { + return true; + } + return RED._("node-red:mqtt.errors.invalid-topic"); + } RED.nodes.registerType('mqtt-broker',{ category: 'config', defaults: {