Merge pull request #526 from glowing-bear/fix-filter-escaping-issues
Fix filter issues
This commit is contained in:
commit
a968d2833f
1 changed files with 11 additions and 2 deletions
|
@ -30,6 +30,13 @@ weechat.filter('irclinky', ['$filter', function($filter) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First, escape entities to prevent escaping issues because it's a bad idea
|
||||||
|
// to parse/modify HTML with regexes, which we do a couple of lines down...
|
||||||
|
var entities = {"<": "<", ">": ">", '"': '"', "'": ''', "&": "&", "/": '/'};
|
||||||
|
text = text.replace(/[<>"'&\/]/g, function (char) {
|
||||||
|
return entities[char];
|
||||||
|
});
|
||||||
|
|
||||||
// This regex in no way matches all IRC channel names (they could also begin with &, + or an
|
// This regex in no way matches all IRC channel names (they could also begin with &, + or an
|
||||||
// exclamation mark followed by 5 alphanumeric characters, and are bounded in length by 50).
|
// exclamation mark followed by 5 alphanumeric characters, and are bounded in length by 50).
|
||||||
// However, it matches all *common* IRC channels while trying to minimise false positives.
|
// However, it matches all *common* IRC channels while trying to minimise false positives.
|
||||||
|
@ -87,13 +94,15 @@ weechat.filter('DOMfilter', ['$filter', '$sce', function($filter, $sce) {
|
||||||
} else {
|
} else {
|
||||||
parent.appendChild(newNode);
|
parent.appendChild(newNode);
|
||||||
}
|
}
|
||||||
|
return newNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// recurse
|
// recurse
|
||||||
|
if (node === undefined || node === null) return;
|
||||||
node = node.firstChild;
|
node = node.firstChild;
|
||||||
while (node) {
|
while (node) {
|
||||||
process(node);
|
var nextNode = process(node);
|
||||||
node = node.nextSibling;
|
node = (nextNode ? nextNode : node).nextSibling;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue