Fix regression in URL rules validation

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/665

Regression:
- 2f63fb3fd4
This commit is contained in:
Raymond Hill 2019-07-10 17:24:01 -04:00
parent 9a95fbff94
commit 874e92af2d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 10 additions and 4 deletions

View File

@ -65,7 +65,7 @@ CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => {
};
const isURLRule = ( ) => {
return /^[\w-_]+:\/\/[^/]+\//.test(tokens[1]);
return tokens[1].indexOf('://') > 0;
};
const skipToEnd = (stream, style = null) => {
@ -132,7 +132,10 @@ CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => {
return null;
}
// URL rule
if ( /[^a-z_-]+/.test(token) || invalidURLRuleTypes.has(token) ) {
if (
/[^a-z_-]/.test(token) && token !== '*' ||
invalidURLRuleTypes.has(token)
) {
return skipToEnd(stream, 'error');
}
return null;

View File

@ -340,8 +340,11 @@ URLNetFiltering.prototype.fromString = function(text) {
URLNetFiltering.prototype.validateRuleParts = function(parts) {
if ( parts.length !== 4 ) { return; }
if ( parts[1].indexOf('://') === -1 ) { return; }
if ( /[^a-z_-]+/.test(parts[2]) || knownInvalidTypes.has(parts[2]) ) {
if ( parts[1].indexOf('://') <= 0 ) { return; }
if (
/[^a-z_-]/.test(parts[2]) && parts[2] !== '*' ||
knownInvalidTypes.has(parts[2])
) {
return;
}
if ( nameToActionMap.hasOwnProperty(parts[3]) === false ) { return; }