| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 return false; | 47 return false; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 let verifyKeyException = function(token, url, docDomain) | 50 let verifyKeyException = function(token, url, docDomain) |
| 51 { | 51 { |
| 52 let match = token.match(/((.*?)=*)_(.*)/); | 52 let match = token.match(/((.*?)=*)_(.*)/); |
| 53 if (!match) | 53 if (!match) |
| 54 return false; // invalid format | 54 return false; // invalid format |
| 55 | 55 |
| 56 if (!defaultMatcher.matchesByKey(url, match[2], docDomain)) | 56 let strippedKey = match[2]; |
|
Felix Dahlke
2014/01/18 13:39:19
I think this would be easier to follow if you'd as
Sebastian Noack
2014/01/19 10:19:40
Done.
| |
| 57 if (!defaultMatcher.matchesByKey(url, strippedKey, docDomain)) | |
| 57 return false; // unknown key | 58 return false; // unknown key |
| 58 | 59 |
| 59 let uri = new URI(url); | 60 let uri = new URI(url); |
| 60 let params = [ | 61 let params = [ |
| 61 uri.path, // REQUEST_URI | 62 uri.path, // REQUEST_URI |
| 62 uri.asciiHost + (uri.port != -1 ? ":" + uri.port : ""), // HTTP_HOST | 63 uri.asciiHost + (uri.port != -1 ? ":" + uri.port : ""), // HTTP_HOST |
| 63 window.navigator.userAgent // HTTP_USER_AGENT | 64 window.navigator.userAgent // HTTP_USER_AGENT |
| 64 ]; | 65 ]; |
| 65 | 66 |
| 66 return verifySignature(match[1], match[3], params.join("\0")); | 67 let key = match[1]; |
| 68 let signature = match[3]; | |
| 69 return verifySignature(key, signature, params.join("\0")); | |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 let recordKeyException = function(tab, url) | 72 let recordKeyException = function(tab, url) |
| 70 { | 73 { |
| 71 let urlsWithKeyException = tabsWithKeyException.get(tab); | 74 let urlsWithKeyException = tabsWithKeyException.get(tab); |
| 72 | 75 |
| 73 if (!urlsWithKeyException) | 76 if (!urlsWithKeyException) |
| 74 { | 77 { |
| 75 urlsWithKeyException = {__proto__: null}; | 78 urlsWithKeyException = {__proto__: null}; |
| 76 tabsWithKeyException.set(tab, urlsWithKeyException); | 79 tabsWithKeyException.set(tab, urlsWithKeyException); |
| 77 } | 80 } |
| 78 | 81 |
| 79 urlsWithKeyException[url] = null; | 82 urlsWithKeyException[url] = null; |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 let processKeyException = exports.processKeyException = function(token, tab, fra me) | 85 let processKeyException = exports.processKeyException = function(token, tab, fra me) |
| 83 { | 86 { |
| 84 let url = stripFragmentFromURL(frame.url); | 87 let url = stripFragmentFromURL(frame.url); |
| 85 let docDomain = extractHostFromURL((frame.parent || frame).url); | 88 let docDomain = extractHostFromURL((frame.parent || frame).url); |
| 86 | 89 |
| 87 if (verifyKeyException(token, url, docDomain)) | 90 if (verifyKeyException(token, url, docDomain)) |
| 88 recordKeyException(tab, url); | 91 recordKeyException(tab, url); |
| 89 }; | 92 }; |
| LEFT | RIGHT |