| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 25 matching lines...) Expand all Loading... | |
| 36 * @class | 36 * @class |
| 37 */ | 37 */ |
| 38 var Policy = exports.Policy = | 38 var Policy = exports.Policy = |
| 39 { | 39 { |
| 40 /** | 40 /** |
| 41 * Set of explicitly supported content types | 41 * Set of explicitly supported content types |
| 42 * @type Set.<string> | 42 * @type Set.<string> |
| 43 */ | 43 */ |
| 44 contentTypes: new Set([ | 44 contentTypes: new Set([ |
| 45 "OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCUMENT", "DOCUMENT ", | 45 "OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCUMENT", "DOCUMENT ", |
| 46 "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA", "ELEMHIDE", "POPUP", | 46 "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA", "PING", "ELEMHIDE", |
| 47 "GENERICHIDE", "GENERICBLOCK" | 47 "POPUP", "GENERICHIDE", "GENERICBLOCK" |
| 48 ]), | 48 ]), |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Set of content types that aren't associated with a visual document area | 51 * Set of content types that aren't associated with a visual document area |
| 52 * @type Set.<string> | 52 * @type Set.<string> |
| 53 */ | 53 */ |
| 54 nonVisualTypes: new Set([ | 54 nonVisualTypes: new Set([ |
| 55 "SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", | 55 "SCRIPT", "STYLESHEET", "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", |
| 56 "ELEMHIDE", "POPUP", "GENERICHIDE", "GENERICBLOCK" | 56 "PING", "ELEMHIDE", "POPUP", "GENERICHIDE", "GENERICBLOCK" |
| 57 ]), | 57 ]), |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Map containing all schemes that should be ignored by content policy. | 60 * Map containing all schemes that should be ignored by content policy. |
| 61 * @type Set.<string> | 61 * @type Set.<string> |
| 62 */ | 62 */ |
| 63 whitelistSchemes: new Set(), | 63 whitelistSchemes: new Set(), |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Called on module startup, initializes various exported properties. | 66 * Called on module startup, initializes various exported properties. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 118 |
| 119 function response(allow, collapse) | 119 function response(allow, collapse) |
| 120 { | 120 { |
| 121 return {allow, collapse, hits}; | 121 return {allow, collapse, hits}; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Ignore whitelisted schemes | 124 // Ignore whitelisted schemes |
| 125 if (!this.isBlockableScheme(location)) | 125 if (!this.isBlockableScheme(location)) |
| 126 return response(true, false); | 126 return response(true, false); |
| 127 | 127 |
| 128 // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the | |
| 129 // same concept - merely generalized. | |
|
Sebastian Noack
2015/12/23 13:34:45
I'm inclined to also add a note that we cannot dis
Wladimir Palant
2015/12/23 14:14:34
That means fairly little for Firefox - we wouldn't
Sebastian Noack
2015/12/23 14:18:18
Well, given that Chrome is our largest platform, I
| |
| 130 if (contentType == "BEACON") | |
| 131 contentType = "PING"; | |
| 132 | |
| 128 // Interpret unknown types as "other" | 133 // Interpret unknown types as "other" |
| 129 if (!this.contentTypes.has(contentType)) | 134 if (!this.contentTypes.has(contentType)) |
| 130 contentType = "OTHER"; | 135 contentType = "OTHER"; |
| 131 | 136 |
| 132 let wndLocation = frames[0].location; | 137 let wndLocation = frames[0].location; |
| 133 let docDomain = getHostname(wndLocation); | 138 let docDomain = getHostname(wndLocation); |
| 134 let match = null; | 139 let match = null; |
| 135 let [sitekey, sitekeyFrame] = getSitekey(frames); | 140 let [sitekey, sitekeyFrame] = getSitekey(frames); |
| 136 let nogeneric = false; | 141 let nogeneric = false; |
| 137 if (!match && Prefs.enabled) | 142 if (!match && Prefs.enabled) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 { | 400 { |
| 396 // EffectiveTLDService throws on IP addresses, just compare the host name | 401 // EffectiveTLDService throws on IP addresses, just compare the host name |
| 397 let host = ""; | 402 let host = ""; |
| 398 try | 403 try |
| 399 { | 404 { |
| 400 host = uri.host; | 405 host = uri.host; |
| 401 } catch (e) {} | 406 } catch (e) {} |
| 402 return host != docDomain; | 407 return host != docDomain; |
| 403 } | 408 } |
| 404 } | 409 } |
| OLD | NEW |