diff --git a/www/js/ui.js b/www/js/ui.js index bb14e4fe..17d1d97c 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -582,6 +582,13 @@ $("#cs-chatfilters-newsubmit").click(function () { var regex = $("#cs-chatfilters-newregex").val(); var flags = $("#cs-chatfilters-newflags").val(); var replace = $("#cs-chatfilters-newreplace").val(); + var entcheck = checkEntitiesInStr(regex); + if (entcheck) { + alert("Warning: " + entcheck.src + " will be replaced by " + + entcheck.replace + " in the message preprocessor. This " + + "regular expression may not match what you intended it to " + + "match."); + } try { new RegExp(regex, flags); diff --git a/www/js/util.js b/www/js/util.js index 0b4291c4..ec8f4521 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -2127,6 +2127,25 @@ function formatCSBanlist() { }); } +function checkEntitiesInStr(str) { + var entities = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "(": "(", + ")": ")" + }; + + var m = str.match(/([&<>"'\(\)])/); + if (m && m[1] in entities) { + return { src: m[1], replace: entities[m[1]] }; + } else { + return false; + } +} + function formatCSChatFilterList() { var tbl = $("#cs-chatfilters table"); tbl.find("tbody").remove(); @@ -2204,6 +2223,13 @@ function formatCSChatFilterList() { $("").addClass("glyphicon glyphicon-floppy-save").appendTo(save); save.click(function () { f.source = regex.val(); + var entcheck = checkEntitiesInStr(f.source); + if (entcheck) { + alert("Warning: " + entcheck.src + " will be replaced by " + + entcheck.replace + " in the message preprocessor. This " + + "regular expression may not match what you intended it to " + + "match."); + } f.flags = flags.val(); f.replace = replace.val(); f.filterlinks = filterlinks.prop("checked");