app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/image_data.js in pageflow-linkmap-page-1.0.0 vs app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/image_data.js in pageflow-linkmap-page-1.1.0

- old
+ new

@@ -25,10 +25,13 @@ data[i + 1] != color[1] || data[i + 2] != color[2]) { data[i + 3] = 0; } + else { + data[i + 3] = 255; + } } destinationContext.putImageData(imageData, destinationX, destinationY); }; @@ -40,11 +43,24 @@ var context = canvas.getContext('2d'); return context.getImageData(left, top, width, height); }; this.toDataURL = function() { - return canvas.toDataURL(); + var result = canvas.toDataURL(); + + if (!result.match(/^data:image/)) { + throw new invalidImageDataUrl(); + } + + return result; }; + } + + function invalidImageDataUrl() { + var error = new Error('Invalid data url from canvas.'); + error.i18nKey = 'pageflow.linkmap_page.errors.invalid_image_data'; + + return error; } ImageData.load = function(url) { return pageflow.linkmapPage.RemoteImage.load(url).then(function(image) { var imageData = new ImageData(image.width(), image.height());