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

Unified Diff: lib/contentPolicy.js

Issue 29333097: Isssue 3459 - Map the content type IMAGESET to IMAGE and FETCH to XMLHTTPREQUEST (Closed)
Patch Set: Created Dec. 28, 2015, 4:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentPolicy.js
===================================================================
--- a/lib/contentPolicy.js
+++ b/lib/contentPolicy.js
@@ -48,6 +48,22 @@
]),
/**
+ *
+ */
+ contentTypesMap: new Map([
+ // Treat navigator.sendBeacon() the same as <a ping>,
+ // it's essentially the same concept - merely generalized.
+ ["BEACON", "PING"],
+
+ // Treat <img srcset> and <picture> the same as other images.
+ ["IMAGESET", "IMAGE"],
+
+ // Treat fetch() the same as XMLHttpRequest,
+ // it's essentially the same - merely a more modern API.
+ ["FETCH", "XMLHTTPREQUEST"]
+ ]),
+
+ /**
* Set of content types that aren't associated with a visual document area
* @type Set.<string>
*/
@@ -67,6 +83,9 @@
*/
init: function()
{
+ for (let contentType of this.contentTypes)
+ this.contentTypesMap.set(contentType, contentType);
+
// whitelisted URL schemes
for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
this.whitelistSchemes.add(scheme);
@@ -125,14 +144,8 @@
if (!this.isBlockableScheme(location))
return response(true, false);
- // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the
- // same concept - merely generalized.
- if (contentType == "BEACON")
- contentType = "PING";
-
// Interpret unknown types as "other"
- if (!this.contentTypes.has(contentType))
- contentType = "OTHER";
+ contentType = this.contentTypesMap.get(contentType) || "OTHER";
let wndLocation = frames[0].location;
let docDomain = getHostname(wndLocation);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld