LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 for (let [domain, isIncluded] of filter.domains) | 76 for (let [domain, isIncluded] of filter.domains) |
77 { | 77 { |
78 if (domain != "") | 78 if (domain != "") |
79 domains.push(isIncluded ? domain : "~" + domain); | 79 domains.push(isIncluded ? domain : "~" + domain); |
80 } | 80 } |
81 } | 81 } |
82 result.push("domains=" + domains.sort().join("|")); | 82 result.push("domains=" + domains.sort().join("|")); |
83 | 83 |
84 if (filter instanceof RegExpFilter) | 84 if (filter instanceof RegExpFilter) |
85 { | 85 { |
86 result.push("regexp=" + filter.regexp.source); | 86 result.push("regexp=" + (filter.regexp ? filter.regexp.source : null)); |
87 result.push("contentType=" + filter.contentType); | 87 result.push("contentType=" + filter.contentType); |
88 result.push("matchCase=" + filter.matchCase); | 88 result.push("matchCase=" + filter.matchCase); |
89 | 89 |
90 let sitekeys = filter.sitekeys || []; | 90 let sitekeys = filter.sitekeys || []; |
91 result.push("sitekeys=" + sitekeys.slice().sort().join("|")); | 91 result.push("sitekeys=" + sitekeys.slice().sort().join("|")); |
92 | 92 |
93 result.push("thirdParty=" + filter.thirdParty); | 93 result.push("thirdParty=" + filter.thirdParty); |
94 if (filter instanceof BlockingFilter) | 94 if (filter instanceof BlockingFilter) |
95 { | 95 { |
96 result.push("type=filterlist"); | 96 result.push("type=filterlist"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 { | 153 { |
154 addProperty("disabled", "false"); | 154 addProperty("disabled", "false"); |
155 addProperty("lastHit", "0"); | 155 addProperty("lastHit", "0"); |
156 addProperty("hitCount", "0"); | 156 addProperty("hitCount", "0"); |
157 } | 157 } |
158 if (type == "whitelist" || type == "filterlist") | 158 if (type == "whitelist" || type == "filterlist") |
159 { | 159 { |
160 addProperty("contentType", 0x7FFFFFFF & ~( | 160 addProperty("contentType", 0x7FFFFFFF & ~( |
161 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.POPUP | t.GENERICHIDE | t.GENERICBLOCK | 161 t.CSP | t.DOCUMENT | t.ELEMHIDE | t.POPUP | t.GENERICHIDE | t.GENERICBLOCK |
162 )); | 162 )); |
| 163 addProperty("regexp", "null"); |
163 addProperty("matchCase", "false"); | 164 addProperty("matchCase", "false"); |
164 addProperty("thirdParty", "null"); | 165 addProperty("thirdParty", "null"); |
165 addProperty("domains", ""); | 166 addProperty("domains", ""); |
166 addProperty("sitekeys", ""); | 167 addProperty("sitekeys", ""); |
167 } | 168 } |
168 if (type == "filterlist") | 169 if (type == "filterlist") |
169 { | 170 { |
170 addProperty("collapse", "null"); | 171 addProperty("collapse", "null"); |
171 addProperty("csp", "null"); | 172 addProperty("csp", "null"); |
172 addProperty("rewrite", "null"); | 173 addProperty("rewrite", "null"); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 checkElemHideEmulationFilterInvalid("~foo.com"); | 262 checkElemHideEmulationFilterInvalid("~foo.com"); |
262 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); | 263 checkElemHideEmulationFilterInvalid("~foo.com,~bar.com"); |
263 checkElemHideEmulationFilterInvalid("foo"); | 264 checkElemHideEmulationFilterInvalid("foo"); |
264 checkElemHideEmulationFilterInvalid("~foo.com,bar"); | 265 checkElemHideEmulationFilterInvalid("~foo.com,bar"); |
265 | 266 |
266 test.done(); | 267 test.done(); |
267 }; | 268 }; |
268 | 269 |
269 exports.testFiltersWithState = function(test) | 270 exports.testFiltersWithState = function(test) |
270 { | 271 { |
271 compareFilter(test, "blabla", ["type=filterlist", "text=blabla", "regexp=blabl
a"]); | 272 compareFilter(test, "blabla", ["type=filterlist", "text=blabla"]); |
272 compareFilter( | 273 compareFilter( |
273 test, "blabla_default", ["type=filterlist", "text=blabla_default", "regexp=b
labla_default"], | 274 test, "blabla_default", ["type=filterlist", "text=blabla_default"], |
274 filter => | 275 filter => |
275 { | 276 { |
276 filter.disabled = false; | 277 filter.disabled = false; |
277 filter.hitCount = 0; | 278 filter.hitCount = 0; |
278 filter.lastHit = 0; | 279 filter.lastHit = 0; |
279 } | 280 } |
280 ); | 281 ); |
281 compareFilter( | 282 compareFilter( |
282 test, "blabla_non_default", | 283 test, "blabla_non_default", |
283 ["type=filterlist", "text=blabla_non_default", "regexp=blabla_non_default",
"disabled=true", "hitCount=12", "lastHit=20"], | 284 ["type=filterlist", "text=blabla_non_default", "disabled=true", "hitCount=12
", "lastHit=20"], |
284 filter => | 285 filter => |
285 { | 286 { |
286 filter.disabled = true; | 287 filter.disabled = true; |
287 filter.hitCount = 12; | 288 filter.hitCount = 12; |
288 filter.lastHit = 20; | 289 filter.lastHit = 20; |
289 } | 290 } |
290 ); | 291 ); |
291 | 292 |
292 test.done(); | 293 test.done(); |
293 }; | 294 }; |
294 | 295 |
295 exports.testSpecialCharacters = function(test) | 296 exports.testSpecialCharacters = function(test) |
296 { | 297 { |
297 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d"]); | 298 compareFilter(test, "/ddd|f?a[s]d/", ["type=filterlist", "text=/ddd|f?a[s]d/",
"regexp=ddd|f?a[s]d"]); |
298 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "
regexp=asdf.*d.*dd"]); | 299 compareFilter(test, "*asdf*d**dd*", ["type=filterlist", "text=*asdf*d**dd*", "
regexp=asdf.*d.*dd"]); |
299 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd
*|", "regexp=^.*asd\\|f.*d.*dd.*$"]); | 300 compareFilter(test, "|*asd|f*d**dd*|", ["type=filterlist", "text=|*asd|f*d**dd
*|", "regexp=^.*asd\\|f.*d.*dd.*$"]); |
300 compareFilter(test, "dd[]{}$%<>&()d", ["type=filterlist", "text=dd[]{}$%<>&()d
", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d"]); | 301 compareFilter(test, "dd[]{}$%<>&()*d", ["type=filterlist", "text=dd[]{}$%<>&()
*d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\).*d"]); |
301 | 302 |
302 // Leading and trailing wildcards should be left in for rewrite filters (#6868
). | 303 // Leading and trailing wildcards should be left in for rewrite filters (#6868
). |
303 compareFilter(test, "*asdf*d**dd*$rewrite=", ["type=filterlist", "text=*asdf*d
**dd*$rewrite=", "regexp=.*asdf.*d.*dd.*", "rewrite=", "contentType=" + (default
Types & ~(t.SCRIPT | t.SUBDOCUMENT | t.OBJECT | t.OBJECT_SUBREQUEST))]); | 304 compareFilter(test, "*asdf*d**dd*$rewrite=", ["type=filterlist", "text=*asdf*d
**dd*$rewrite=", "regexp=.*asdf.*d.*dd.*", "rewrite=", "contentType=" + (default
Types & ~(t.SCRIPT | t.SUBDOCUMENT | t.OBJECT | t.OBJECT_SUBREQUEST))]); |
304 | 305 |
305 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d
/", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); | 306 compareFilter(test, "@@/ddd|f?a[s]d/", ["type=whitelist", "text=@@/ddd|f?a[s]d
/", "regexp=ddd|f?a[s]d", "contentType=" + defaultTypes]); |
306 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*"
, "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]); | 307 compareFilter(test, "@@*asdf*d**dd*", ["type=whitelist", "text=@@*asdf*d**dd*"
, "regexp=asdf.*d.*dd", "contentType=" + defaultTypes]); |
307 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d*
*dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); | 308 compareFilter(test, "@@|*asd|f*d**dd*|", ["type=whitelist", "text=@@|*asd|f*d*
*dd*|", "regexp=^.*asd\\|f.*d.*dd.*$", "contentType=" + defaultTypes]); |
308 compareFilter(test, "@@dd[]{}$%<>&()d", ["type=whitelist", "text=@@dd[]{}$%<>&
()d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\)d", "contentType=" + defaultTyp
es]); | 309 compareFilter(test, "@@dd[]{}$%<>&()*d", ["type=whitelist", "text=@@dd[]{}$%<>
&()*d", "regexp=dd\\[\\]\\{\\}\\$\\%\\<\\>\\&\\(\\).*d", "contentType=" + defaul
tTypes]); |
309 | 310 |
310 test.done(); | 311 test.done(); |
311 }; | 312 }; |
312 | 313 |
313 exports.testFilterOptions = function(test) | 314 exports.testFilterOptions = function(test) |
314 { | 315 { |
315 compareFilter(test, "bla$match-case,csp=first csp,script,other,third-party,dom
ain=FOO.cOm,sitekey=foo", ["type=filterlist", "text=bla$match-case,csp=first csp
,script,other,third-party,domain=FOO.cOm,sitekey=foo", "regexp=bla", "matchCase=
true", "contentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domain
s=foo.com", "sitekeys=FOO", "csp=first csp"]); | 316 compareFilter(test, "bla$match-case,csp=first csp,script,other,third-party,dom
ain=FOO.cOm,sitekey=foo", ["type=filterlist", "text=bla$match-case,csp=first csp
,script,other,third-party,domain=FOO.cOm,sitekey=foo", "matchCase=true", "conten
tType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=foo.com", "s
itekeys=FOO", "csp=first csp"]); |
316 compareFilter(test, "bla$~match-case,~csp=csp,~script,~other,~third-party,doma
in=~bAr.coM", ["type=filterlist", "text=bla$~match-case,~csp=csp,~script,~other,
~third-party,domain=~bAr.coM", "regexp=bla", "contentType=" + (defaultTypes & ~(
t.SCRIPT | t.OTHER)), "thirdParty=false", "domains=~bar.com"]); | 317 compareFilter(test, "bla$~match-case,~csp=csp,~script,~other,~third-party,doma
in=~bAr.coM", ["type=filterlist", "text=bla$~match-case,~csp=csp,~script,~other,
~third-party,domain=~bAr.coM", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.O
THER)), "thirdParty=false", "domains=~bar.com"]); |
317 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|
bar.com|~bAR.foO.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", ["type=whitelist",
"text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bAR.foO
.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", "regexp=bla", "matchCase=true", "c
ontentType=" + (t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=bar.com
|foo.com|~bar.foo.com|~foo.bar.com", "sitekeys=BAR|FOO"]); | 318 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|
bar.com|~bAR.foO.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", ["type=whitelist",
"text=@@bla$match-case,script,other,third-party,domain=foo.com|bar.com|~bAR.foO
.Com|~Foo.Bar.com,csp=c s p,sitekey=foo|bar", "matchCase=true", "contentType=" +
(t.SCRIPT | t.OTHER | t.CSP), "thirdParty=true", "domains=bar.com|foo.com|~bar.
foo.com|~foo.bar.com", "sitekeys=BAR|FOO"]); |
318 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|
bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@b
la$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.
bar.com,sitekey=foo|bar", "regexp=bla", "matchCase=true", "contentType=" + (t.SC
RIPT | t.OTHER), "thirdParty=true", "domains=bar.com|foo.com|~bar.foo.com|~foo.b
ar.com", "sitekeys=BAR|FOO"]); | 319 compareFilter(test, "@@bla$match-case,script,other,third-party,domain=foo.com|
bar.com|~bar.foo.com|~foo.bar.com,sitekey=foo|bar", ["type=whitelist", "text=@@b
la$match-case,script,other,third-party,domain=foo.com|bar.com|~bar.foo.com|~foo.
bar.com,sitekey=foo|bar", "matchCase=true", "contentType=" + (t.SCRIPT | t.OTHER
), "thirdParty=true", "domains=bar.com|foo.com|~bar.foo.com|~foo.bar.com", "site
keys=BAR|FOO"]); |
319 compareFilter(test, "||content.server.com/files/*.php$rewrite=$1", ["type=filt
erlist", "text=||content.server.com/files/*.php$rewrite=$1", "regexp=^[\\w\\-]+:
\\/+(?!\\/)(?:[^\\/]+\\.)?content\\.server\\.com\\/files\\/.*\\.php", "matchCase
=false", "rewrite=$1", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.SUBDOCUME
NT | t.OBJECT | t.OBJECT_SUBREQUEST))]); | 320 compareFilter(test, "||content.server.com/files/*.php$rewrite=$1", ["type=filt
erlist", "text=||content.server.com/files/*.php$rewrite=$1", "regexp=^[\\w\\-]+:
\\/+(?!\\/)(?:[^\\/]+\\.)?content\\.server\\.com\\/files\\/.*\\.php", "matchCase
=false", "rewrite=$1", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.SUBDOCUME
NT | t.OBJECT | t.OBJECT_SUBREQUEST))]); |
320 | 321 |
321 // background and image should be the same for backwards compatibility | 322 // background and image should be the same for backwards compatibility |
322 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "regexp
=bla", "contentType=" + (t.IMAGE)]); | 323 compareFilter(test, "bla$image", ["type=filterlist", "text=bla$image", "conten
tType=" + (t.IMAGE)]); |
323 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background
", "regexp=bla", "contentType=" + (t.IMAGE)]); | 324 compareFilter(test, "bla$background", ["type=filterlist", "text=bla$background
", "contentType=" + (t.IMAGE)]); |
324 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "rege
xp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); | 325 compareFilter(test, "bla$~image", ["type=filterlist", "text=bla$~image", "cont
entType=" + (defaultTypes & ~t.IMAGE)]); |
325 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou
nd", "regexp=bla", "contentType=" + (defaultTypes & ~t.IMAGE)]); | 326 compareFilter(test, "bla$~background", ["type=filterlist", "text=bla$~backgrou
nd", "contentType=" + (defaultTypes & ~t.IMAGE)]); |
326 | 327 |
327 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc
ript,~other", "regexp=bla", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE
R))]); | 328 compareFilter(test, "@@bla$~script,~other", ["type=whitelist", "text=@@bla$~sc
ript,~other", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHER))]); |
328 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@
http://bla$~script,~other", "regexp=http\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); | 329 compareFilter(test, "@@http://bla$~script,~other", ["type=whitelist", "text=@@
http://bla$~script,~other", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.OTHE
R))]); |
329 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@
|ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); | 330 compareFilter(test, "@@|ftp://bla$~script,~other", ["type=whitelist", "text=@@
|ftp://bla$~script,~other", "regexp=^ftp\\:\\/\\/bla", "contentType=" + (default
Types & ~(t.SCRIPT | t.OTHER))]); |
330 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text=
@@bla$~script,~other,document", "regexp=bla", "contentType=" + (defaultTypes & ~
(t.SCRIPT | t.OTHER) | t.DOCUMENT)]); | 331 compareFilter(test, "@@bla$~script,~other,document", ["type=whitelist", "text=
@@bla$~script,~other,document", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.
OTHER) | t.DOCUMENT)]); |
331 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text
=@@bla$~script,~other,~document", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); | 332 compareFilter(test, "@@bla$~script,~other,~document", ["type=whitelist", "text
=@@bla$~script,~other,~document", "contentType=" + (defaultTypes & ~(t.SCRIPT |
t.OTHER))]); |
332 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document"
, "regexp=bla", "contentType=" + t.DOCUMENT]); | 333 compareFilter(test, "@@bla$document", ["type=whitelist", "text=@@bla$document"
, "contentType=" + t.DOCUMENT]); |
333 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text=
@@bla$~script,~other,elemhide", "regexp=bla", "contentType=" + (defaultTypes & ~
(t.SCRIPT | t.OTHER) | t.ELEMHIDE)]); | 334 compareFilter(test, "@@bla$~script,~other,elemhide", ["type=whitelist", "text=
@@bla$~script,~other,elemhide", "contentType=" + (defaultTypes & ~(t.SCRIPT | t.
OTHER) | t.ELEMHIDE)]); |
334 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text
=@@bla$~script,~other,~elemhide", "regexp=bla", "contentType=" + (defaultTypes &
~(t.SCRIPT | t.OTHER))]); | 335 compareFilter(test, "@@bla$~script,~other,~elemhide", ["type=whitelist", "text
=@@bla$~script,~other,~elemhide", "contentType=" + (defaultTypes & ~(t.SCRIPT |
t.OTHER))]); |
335 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide"
, "regexp=bla", "contentType=" + t.ELEMHIDE]); | 336 compareFilter(test, "@@bla$elemhide", ["type=whitelist", "text=@@bla$elemhide"
, "contentType=" + t.ELEMHIDE]); |
336 | 337 |
337 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text=
@@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); | 338 compareFilter(test, "@@bla$~script,~other,donottrack", ["type=invalid", "text=
@@bla$~script,~other,donottrack", "reason=filter_unknown_option"]); |
338 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text
=@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); | 339 compareFilter(test, "@@bla$~script,~other,~donottrack", ["type=invalid", "text
=@@bla$~script,~other,~donottrack", "reason=filter_unknown_option"]); |
339 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac
k", "reason=filter_unknown_option"]); | 340 compareFilter(test, "@@bla$donottrack", ["type=invalid", "text=@@bla$donottrac
k", "reason=filter_unknown_option"]); |
340 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea
son=filter_unknown_option"]); | 341 compareFilter(test, "@@bla$foobar", ["type=invalid", "text=@@bla$foobar", "rea
son=filter_unknown_option"]); |
341 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f
oobar", "reason=filter_unknown_option"]); | 342 compareFilter(test, "@@bla$image,foobar", ["type=invalid", "text=@@bla$image,f
oobar", "reason=filter_unknown_option"]); |
342 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,
image", "reason=filter_unknown_option"]); | 343 compareFilter(test, "@@bla$foobar,image", ["type=invalid", "text=@@bla$foobar,
image", "reason=filter_unknown_option"]); |
343 | 344 |
344 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter
_invalid_csp"]); | 345 compareFilter(test, "bla$csp", ["type=invalid", "text=bla$csp", "reason=filter
_invalid_csp"]); |
345 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt
er_invalid_csp"]); | 346 compareFilter(test, "bla$csp=", ["type=invalid", "text=bla$csp=", "reason=filt
er_invalid_csp"]); |
346 | 347 |
347 // Blank CSP values are allowed for whitelist filters. | 348 // Blank CSP values are allowed for whitelist filters. |
348 compareFilter(test, "@@bla$csp", ["type=whitelist", "text=@@bla$csp", "regexp=
bla", "contentType=" + t.CSP]); | 349 compareFilter(test, "@@bla$csp", ["type=whitelist", "text=@@bla$csp", "content
Type=" + t.CSP]); |
349 compareFilter(test, "@@bla$csp=", ["type=whitelist", "text=@@bla$csp=", "regex
p=bla", "contentType=" + t.CSP]); | 350 compareFilter(test, "@@bla$csp=", ["type=whitelist", "text=@@bla$csp=", "conte
ntType=" + t.CSP]); |
350 | 351 |
351 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor
t-uri", "reason=filter_invalid_csp"]); | 352 compareFilter(test, "bla$csp=report-uri", ["type=invalid", "text=bla$csp=repor
t-uri", "reason=filter_invalid_csp"]); |
352 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs
p=foo,csp=report-to", "reason=filter_invalid_csp"]); | 353 compareFilter(test, "bla$csp=foo,csp=report-to", ["type=invalid", "text=bla$cs
p=foo,csp=report-to", "reason=filter_invalid_csp"]); |
353 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla
$csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); | 354 compareFilter(test, "bla$csp=foo,csp=referrer foo", ["type=invalid", "text=bla
$csp=foo,csp=referrer foo", "reason=filter_invalid_csp"]); |
354 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp
=foo,csp=base-uri", "reason=filter_invalid_csp"]); | 355 compareFilter(test, "bla$csp=foo,csp=base-uri", ["type=invalid", "text=bla$csp
=foo,csp=base-uri", "reason=filter_invalid_csp"]); |
355 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali
d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp
"]); | 356 compareFilter(test, "bla$csp=foo,csp=upgrade-insecure-requests", ["type=invali
d", "text=bla$csp=foo,csp=upgrade-insecure-requests", "reason=filter_invalid_csp
"]); |
356 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp
=foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); | 357 compareFilter(test, "bla$csp=foo,csp=ReFeRReR", ["type=invalid", "text=bla$csp
=foo,csp=ReFeRReR", "reason=filter_invalid_csp"]); |
357 | 358 |
358 test.done(); | 359 test.done(); |
359 }; | 360 }; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 normalized, | 508 normalized, |
508 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" | 509 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" |
509 ); | 510 ); |
510 compareFilter( | 511 compareFilter( |
511 test, normalized, [ | 512 test, normalized, [ |
512 "type=filterlist", | 513 "type=filterlist", |
513 "text=" + normalized, | 514 "text=" + normalized, |
514 "csp=c s p", | 515 "csp=c s p", |
515 "domains=domain.com|foo.com", | 516 "domains=domain.com|foo.com", |
516 "sitekeys=FOO", | 517 "sitekeys=FOO", |
517 "regexp=b\\$la", | |
518 "contentType=" + t.CSP | 518 "contentType=" + t.CSP |
519 ] | 519 ] |
520 ); | 520 ); |
521 | 521 |
522 // Some $csp edge cases | 522 // Some $csp edge cases |
523 test.equal(Filter.normalize("$csp= "), | 523 test.equal(Filter.normalize("$csp= "), |
524 "$csp="); | 524 "$csp="); |
525 test.equal(Filter.normalize("$csp= c s p"), | 525 test.equal(Filter.normalize("$csp= c s p"), |
526 "$csp=c s p"); | 526 "$csp=c s p"); |
527 test.equal(Filter.normalize("$$csp= c s p"), | 527 test.equal(Filter.normalize("$$csp= c s p"), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 628 |
629 test.notEqual(filter2.domains, filter5.domains); | 629 test.notEqual(filter2.domains, filter5.domains); |
630 | 630 |
631 // Check twice for element hiding filters to make sure the internal cached | 631 // Check twice for element hiding filters to make sure the internal cached |
632 // values are also not equal. | 632 // values are also not equal. |
633 test.notEqual(filter4.domains, filter6.domains); | 633 test.notEqual(filter4.domains, filter6.domains); |
634 test.notEqual(filter4.domains, filter6.domains); | 634 test.notEqual(filter4.domains, filter6.domains); |
635 | 635 |
636 test.done(); | 636 test.done(); |
637 }; | 637 }; |
LEFT | RIGHT |