From 9384618641d017decd6e1cb2cf43be13283ffd75 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 11 Mar 2016 18:42:45 +0700 Subject: [PATCH 1/2] Fix cross-domain images and images with relative urls or without explicit protocol --- problem_builder/public/js/dashboard.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/problem_builder/public/js/dashboard.js b/problem_builder/public/js/dashboard.js index fdd4ef99..bb7e879a 100644 --- a/problem_builder/public/js/dashboard.js +++ b/problem_builder/public/js/dashboard.js @@ -8,6 +8,18 @@ function PBDashboardBlock(runtime, element, initData) { var generateDataUriFromImageURL = function(imgURL) { // Given the URL to an image, IF the image has already been cached by the browser, // returns a data: URI with the contents of the image (image will be converted to PNG) + + // Expand relative urls and urls without an explicit protocol into absolute urls + var a = document.createElement('a'); + a.href = imgURL; + imgURL = a.href; + + // If the image is from another domain, just return its URL. We can't + // create a data URL from cross-domain images: + // https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-todataurl + if (a.origin !== window.location.origin) + return imgURL; + var img = new Image(); img.src = imgURL; if (!img.complete) From 85f9a263797540cb4b70d0ad26a6575e4ec22990 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Fri, 11 Mar 2016 18:42:53 +0700 Subject: [PATCH 2/2] Bump version number --- .travis.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb16d3bf..8fce79f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: - "pip install -r requirements.txt" - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt" - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt" - - "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.0.2.tar.gz" + - "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.0.3.tar.gz" - "pip install -r test_requirements.txt" - "mkdir var" script: diff --git a/setup.py b/setup.py index 908e163a..d649c384 100644 --- a/setup.py +++ b/setup.py @@ -75,7 +75,7 @@ def package_data(pkg, root_list): setup( name='xblock-problem-builder', - version='2.0.2', + version='2.0.3', description='XBlock - Problem Builder', packages=['problem_builder', 'problem_builder.v1'], install_requires=[