From 590dd6f1cf726c477db3a97e8f742bf6e1a9fb07 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 9 Oct 2017 12:46:34 +0200 Subject: [PATCH] Always create a new blank image to avoid CSP violations --- src/ol/imagetile.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index ad7acec21c..139d5b0e46 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -61,7 +61,7 @@ ol.inherits(ol.ImageTile, ol.Tile); ol.ImageTile.prototype.disposeInternal = function() { if (this.state == ol.TileState.LOADING) { this.unlistenImage_(); - this.image_.src = ol.ImageTile.blankImageUrl; + this.image_ = ol.ImageTile.getBlankImage(); } if (this.interimTile) { this.interimTile.dispose(); @@ -98,7 +98,7 @@ ol.ImageTile.prototype.getKey = function() { ol.ImageTile.prototype.handleImageError_ = function() { this.state = ol.TileState.ERROR; this.unlistenImage_(); - this.image_.src = ol.ImageTile.blankImageUrl; + this.image_ = ol.ImageTile.getBlankImage(); this.changed(); }; @@ -150,12 +150,12 @@ ol.ImageTile.prototype.unlistenImage_ = function() { /** - * Data URI for a blank image. - * @type {string} + * Get a 1-pixel blank image. + * @return {HTMLCanvasElement} Blank image. */ -ol.ImageTile.blankImageUrl = (function() { +ol.ImageTile.getBlankImage = function() { var ctx = ol.dom.createCanvasContext2D(1, 1); ctx.fillStyle = 'rgba(0,0,0,0)'; ctx.fillRect(0, 0, 1, 1); - return ctx.canvas.toDataURL('image/png'); -})(); + return ctx.canvas; +};