מדיה ויקי:Gadget-Checkty.js – הבדלי גרסאות

תוכן שנמחק תוכן שנוסף
מ escape נכון - \\ במקום \
מ תיקון באג בטיפול בביטוים רגולריים להחרגה. (אלו ביטויים רגולריים ולא מחרוזות)
שורה 103:
}],
regexes: [],
ignoreStringsignoreRegexs: [],
run: function () {
if (this != chectTyTool) {
שורה 387:
}
if (data) {
var lines = data.split(/\n/);,
var clear_nowiki = /\|<nowiki>(.*)<\/nowiki>/;,
var protect_title_regex = /\[\[(.+?)\]\]/g;,
var matches, regex, pTitle;
while (lines.length) {
if (!(matches = lines.shift().match(/^\|(\d+)/))) continue;
שורה 403:
if (!(matches = lines.shift().match(clear_nowiki))) continue;
this.regexes[num] = [regex, matches[1]];
var ignore = lines.shift().replace(/\||<\/?nowiki>/g, '')ignoreRegex;
ignoreif (ignoreRegex = /^\|(?:<nowiki>)?(.+?)(?:<\/nowiki>)?$/.trimexec(ignore);){
if (ignore) this.ignoreStringsignoreRegexs.push(mw.util.escapeRegExp'(ignore?:' + ignoreRegex[1] + ')');
}
}
if (protect) {
// add titles of pages explicitly marked as special
while (pTitle = protect_title_regex.exec(protect)) {
this.ignoreStringsignoreRegexs.push(mw.util.escapeRegExp(pTitle[1]));
this.ignoreStringsignoreRegexs.push('(?:\\[\\[' + mw.util.escapeRegExp(pTitle[1]) + '\\|.+?\\]\\])'); //protect links [[A (x)|A]] or other variations
}
}
שורה 445 ⟵ 446:
}
var specials = [],
ignoreRegex = new RegExp('(' + this.ignoreStringsignoreRegexs.join('|') + ')');
for (i in this.regexes) // assume regexs on templates are safe if contain template wikicode
if (/\\{\\{/.test(this.regexes[i][0]) && this.regexes[i][0].test(t)) {
שורה 454 ⟵ 455:
while (true) { //extract inner links, inner templates and inner params - we don't want to sptit those.
match = t.match(/(\{\{[^\{\}]*\}\}|(\n|\[\[)(?:File|קובץ|תמונה|Image):.*?[\|\n]|[^\[\0]\[[^\{\}\[]*\])/);
if ((!match || !match.length) && this.ignoreStringsignoreRegexs.length ) match = t.match(ignoreRegex);
if (!match || !match.length) break;
specials.push(match[0]);