1+ "use strict" ;
12// Stubs so this runs under nodejs. They get overwritten later by util.js
23var DBUG = 1 ;
34function log ( ) { } ;
@@ -87,16 +88,14 @@ RuleSet.prototype = {
8788
8889/**
8990 * Initialize Rule Sets
90- * @param userAgent The browser's user agent
9191 * @param cache a cache object (lru)
9292 * @param ruleActiveStates default state for rules
9393 * @constructor
9494 */
95- function RuleSets ( userAgent , cache , ruleActiveStates ) {
95+ function RuleSets ( cache , ruleActiveStates ) {
9696 // Load rules into structure
9797 var t1 = new Date ( ) . getTime ( ) ;
9898 this . targets = { } ;
99- this . userAgent = userAgent ;
10099
101100 // A cache for potentiallyApplicableRulesets
102101 // Size chosen /completely/ arbitrarily.
@@ -107,6 +106,9 @@ function RuleSets(userAgent, cache, ruleActiveStates) {
107106
108107 // A hash of rule name -> active status (true/false).
109108 this . ruleActiveStates = ruleActiveStates ;
109+
110+ // A regex to match platform-specific features
111+ this . localPlatformRegexp = new RegExp ( "chromium" ) ;
110112}
111113
112114
@@ -125,21 +127,6 @@ RuleSets.prototype = {
125127 }
126128 } ,
127129
128- /**
129- * Return the RegExp for the local platform
130- */
131- localPlatformRegexp : ( function ( ) {
132- var isOpera = / (?: O P R | O p e r a ) [ \/ \s ] ( \d + ) (?: \. \d + ) / . test ( this . userAgent ) ;
133- if ( isOpera && isOpera . length === 2 && parseInt ( isOpera [ 1 ] ) < 23 ) {
134- // Opera <23 does not have mixed content blocking
135- log ( DBUG , 'Detected that we are running Opera < 23' ) ;
136- return new RegExp ( "chromium|mixedcontent" ) ;
137- } else {
138- log ( DBUG , 'Detected that we are running Chrome/Chromium' ) ;
139- return new RegExp ( "chromium" ) ;
140- }
141- } ) ( ) ,
142-
143130 /**
144131 * Load a user rule
145132 * @param params
@@ -177,7 +164,7 @@ RuleSets.prototype = {
177164 }
178165
179166 // If a ruleset declares a platform, and we don't match it, treat it as
180- // off-by-default
167+ // off-by-default. In practice, this excludes "mixedcontent" & "cacert" rules.
181168 var platform = ruletag . getAttribute ( "platform" ) ;
182169 if ( platform ) {
183170 if ( platform . search ( this . localPlatformRegexp ) == - 1 ) {
@@ -274,6 +261,7 @@ RuleSets.prototype = {
274261 }
275262 // now eat away from the left, with *, so that for x.y.z.google.com we
276263 // check *.z.google.com and *.google.com (we did *.y.z.google.com above)
264+ var t ;
277265 for ( var i = 2 ; i <= segmented . length - 2 ; ++ i ) {
278266 t = "*." + segmented . slice ( i , segmented . length ) . join ( "." ) ;
279267 this . setInsert ( results , this . targets [ t ] ) ;
0 commit comments