Skip to content

Commit c620fbf

Browse files
authored
[rules] JSRule: Sanitize passed in rule UID (#360)
This avoids issues with invalid rule UIDs. Signed-off-by: Florian Hotze <[email protected]>
1 parent 5502a39 commit c620fbf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/rules/rules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function setEnabled (uid, isEnabled) {
222222
* @throws {Error} an error if the rule with the passed in uid already exists and {@link RuleConfig.overwrite} is not `true`
223223
*/
224224
function JSRule (ruleConfig) {
225-
const ruleUID = ruleConfig.id || ruleConfig.name.replace(/[^\w]/g, '-') + '-' + randomUUID();
225+
const ruleUID = ruleConfig.id.replace(/\W/g, '-') || ruleConfig.name.replace(/\W/g, '-') + '-' + randomUUID();
226226
if (ruleConfig.overwrite === true) {
227227
removeRule(ruleUID);
228228
}

0 commit comments

Comments
 (0)