mirror of https://github.com/calzoneman/sync.git
Add warning as discussed in #347
This commit is contained in:
parent
cfe34112a4
commit
64980bc293
|
@ -582,6 +582,13 @@ $("#cs-chatfilters-newsubmit").click(function () {
|
||||||
var regex = $("#cs-chatfilters-newregex").val();
|
var regex = $("#cs-chatfilters-newregex").val();
|
||||||
var flags = $("#cs-chatfilters-newflags").val();
|
var flags = $("#cs-chatfilters-newflags").val();
|
||||||
var replace = $("#cs-chatfilters-newreplace").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 {
|
try {
|
||||||
new RegExp(regex, flags);
|
new RegExp(regex, flags);
|
||||||
|
|
|
@ -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() {
|
function formatCSChatFilterList() {
|
||||||
var tbl = $("#cs-chatfilters table");
|
var tbl = $("#cs-chatfilters table");
|
||||||
tbl.find("tbody").remove();
|
tbl.find("tbody").remove();
|
||||||
|
@ -2204,6 +2223,13 @@ function formatCSChatFilterList() {
|
||||||
$("<span/>").addClass("glyphicon glyphicon-floppy-save").appendTo(save);
|
$("<span/>").addClass("glyphicon glyphicon-floppy-save").appendTo(save);
|
||||||
save.click(function () {
|
save.click(function () {
|
||||||
f.source = regex.val();
|
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.flags = flags.val();
|
||||||
f.replace = replace.val();
|
f.replace = replace.val();
|
||||||
f.filterlinks = filterlinks.prop("checked");
|
f.filterlinks = filterlinks.prop("checked");
|
||||||
|
|
Loading…
Reference in New Issue