Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 4559243822759936: Issue 431/432 - Remove special handling for the $sitekey option (Closed)
Left Patch Set: Created Aug. 29, 2014, 3:44 p.m.
Right Patch Set: Made changes for WebKit bug 132872 Created Sept. 1, 2014, 3:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/contentPolicy.js ('k') | lib/matcher.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 * @type Boolean 317 * @type Boolean
318 */ 318 */
319 domainSourceIsUpperCase: false, 319 domainSourceIsUpperCase: false,
320 320
321 /** 321 /**
322 * Map containing domains that this filter should match on/not match on or nul l if the filter should match on all domains 322 * Map containing domains that this filter should match on/not match on or nul l if the filter should match on all domains
323 * @type Object 323 * @type Object
324 */ 324 */
325 get domains() 325 get domains()
326 { 326 {
327 // Despite this property being cached, the getter is called
328 // several times on Safari, due to WebKit bug 132872
329 let prop = Object.getOwnPropertyDescriptor(this, "domains");
330 if (prop)
331 return prop.value;
332
327 let domains = null; 333 let domains = null;
328 334
329 if (this.domainSource) 335 if (this.domainSource)
330 { 336 {
331 let source = this.domainSource; 337 let source = this.domainSource;
332 if (!this.domainSourceIsUpperCase) { 338 if (!this.domainSourceIsUpperCase) {
333 // RegExpFilter already have uppercase domains 339 // RegExpFilter already have uppercase domains
334 source = source.toUpperCase(); 340 source = source.toUpperCase();
335 } 341 }
336 let list = source.split(this.domainSeparator); 342 let list = source.split(this.domainSeparator);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 sitekeys: null, 393 sitekeys: null,
388 394
389 /** 395 /**
390 * Checks whether this filter is active on a domain. 396 * Checks whether this filter is active on a domain.
391 * @param {String} docDomain domain name of the document that loads the URL 397 * @param {String} docDomain domain name of the document that loads the URL
392 * @param {String} [sitekey] public key provided by the document 398 * @param {String} [sitekey] public key provided by the document
393 * @return {Boolean} true in case of the filter being active 399 * @return {Boolean} true in case of the filter being active
394 */ 400 */
395 isActiveOnDomain: function(docDomain, sitekey) 401 isActiveOnDomain: function(docDomain, sitekey)
396 { 402 {
403 // Sitekeys are case-sensitive so we shouldn't convert them to upper-case to avoid false
404 // positives here. Instead we need to change the way filter options are pars ed.
397 if (this.sitekeys && (!sitekey || this.sitekeys.indexOf(sitekey.toUpperCase( )) < 0)) 405 if (this.sitekeys && (!sitekey || this.sitekeys.indexOf(sitekey.toUpperCase( )) < 0))
Wladimir Palant 2014/08/29 20:13:59 Ok, we have an issue here. This code works in the
Thomas Greiner 2014/09/01 09:51:46 Done.
398 return false; 406 return false;
399 407
400 // If no domains are set the rule matches everywhere 408 // If no domains are set the rule matches everywhere
401 if (!this.domains) 409 if (!this.domains)
402 return true; 410 return true;
403 411
404 // If the document has no host name, match only if the filter isn't restrict ed to specific domains 412 // If the document has no host name, match only if the filter isn't restrict ed to specific domains
405 if (!docDomain) 413 if (!docDomain)
406 return this.domains[""]; 414 return this.domains[""];
407 415
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 * Expression from which a regular expression should be generated - for delaye d creation of the regexp property 530 * Expression from which a regular expression should be generated - for delaye d creation of the regexp property
523 * @type String 531 * @type String
524 */ 532 */
525 regexpSource: null, 533 regexpSource: null,
526 /** 534 /**
527 * Regular expression to be used when testing against this filter 535 * Regular expression to be used when testing against this filter
528 * @type RegExp 536 * @type RegExp
529 */ 537 */
530 get regexp() 538 get regexp()
531 { 539 {
540 // Despite this property being cached, the getter is called
541 // several times on Safari, due to WebKit bug 132872
542 let prop = Object.getOwnPropertyDescriptor(this, "regexp");
543 if (prop)
544 return prop.value;
545
532 // Remove multiple wildcards 546 // Remove multiple wildcards
533 let source = this.regexpSource 547 let source = this.regexpSource
534 .replace(/\*+/g, "*") // remove multiple wildcards 548 .replace(/\*+/g, "*") // remove multiple wildcards
535 .replace(/\^\|$/, "^") // remove anchors following separator placeho lder 549 .replace(/\^\|$/, "^") // remove anchors following separator placeho lder
536 .replace(/\W/g, "\\$&") // escape special symbols 550 .replace(/\W/g, "\\$&") // escape special symbols
537 .replace(/\\\*/g, ".*") // replace wildcards by .* 551 .replace(/\\\*/g, ".*") // replace wildcards by .*
538 // process separator placeholders (all ANSI characters but alphanumeric ch aracters and _%.-) 552 // process separator placeholders (all ANSI characters but alphanumeric ch aracters and _%.-)
539 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)") 553 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x7F]|$)")
540 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start 554 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start
541 .replace(/^\\\|/, "^") // process anchor at expression start 555 .replace(/^\\\|/, "^") // process anchor at expression start
(...skipping 26 matching lines...) Expand all
568 * @type String 582 * @type String
569 */ 583 */
570 sitekeySource: null, 584 sitekeySource: null,
571 585
572 /** 586 /**
573 * Array containing public keys of websites that this filter should apply to 587 * Array containing public keys of websites that this filter should apply to
574 * @type Array of String 588 * @type Array of String
575 */ 589 */
576 get sitekeys() 590 get sitekeys()
577 { 591 {
592 // Despite this property being cached, the getter is called
593 // several times on Safari, due to WebKit bug 132872
594 let prop = Object.getOwnPropertyDescriptor(this, "sitekeys");
595 if (prop)
596 return prop.value;
597
578 let sitekeys = null; 598 let sitekeys = null;
579 599
580 if (this.sitekeySource) 600 if (this.sitekeySource)
581 { 601 {
582 sitekeys = this.sitekeySource.split("|"); 602 sitekeys = this.sitekeySource.split("|");
583 this.sitekeySource = null; 603 this.sitekeySource = null;
584 } 604 }
585 605
586 Object.defineProperty(this, "sitekeys", {value: sitekeys, enumerable: true}) ; 606 Object.defineProperty(this, "sitekeys", {value: sitekeys, enumerable: true}) ;
587 return this.sitekeys; 607 return this.sitekeys;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 function ElemHideException(text, domains, selector) 940 function ElemHideException(text, domains, selector)
921 { 941 {
922 ElemHideBase.call(this, text, domains, selector); 942 ElemHideBase.call(this, text, domains, selector);
923 } 943 }
924 exports.ElemHideException = ElemHideException; 944 exports.ElemHideException = ElemHideException;
925 945
926 ElemHideException.prototype = 946 ElemHideException.prototype =
927 { 947 {
928 __proto__: ElemHideBase.prototype 948 __proto__: ElemHideBase.prototype
929 }; 949 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld