1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-03 09:39:38 +02:00

code review re #2132

This commit is contained in:
gorhill 2016-11-08 16:31:04 -05:00
parent 368e00ef7a
commit 6f512f39fb

View File

@ -1419,11 +1419,14 @@ FilterContainer.prototype._lookupUserScript = function(dict, raw, reng, out) {
var content = reng.resourceContentFromName(token, 'application/javascript'); var content = reng.resourceContentFromName(token, 'application/javascript');
if ( !content ) { return; } if ( !content ) { return; }
if ( args ) { if ( args ) {
var i = 1; var i = 1, arg;
while ( args !== '' ) { while ( args !== '' ) {
pos = args.indexOf(','); pos = args.indexOf(',');
if ( pos === -1 ) { pos = args.length; } if ( pos === -1 ) { pos = args.length; }
content = content.replace('{{' + i + '}}', args.slice(0, pos).trim()); arg = args.slice(0, pos).trim();
if ( reArgValidator.test(arg) ) {
content = content.replace('{{' + i + '}}', arg);
}
args = args.slice(pos + 1).trim(); args = args.slice(pos + 1).trim();
i++; i++;
} }
@ -1432,6 +1435,9 @@ FilterContainer.prototype._lookupUserScript = function(dict, raw, reng, out) {
out.push(content); out.push(content);
}; };
// Only accept plain word characters for now.
var reArgValidator = /^\w*$/;
/******************************************************************************/ /******************************************************************************/
FilterContainer.prototype.toSelfie = function() { FilterContainer.prototype.toSelfie = function() {