Ver código fonte

Clean up the pull request that was just merged.

pull/846/head
Matthew Petroff 5 anos atrás
pai
commit
15e0d09fec
1 arquivos alterados com 9 adições e 3 exclusões
  1. +9
    -3
      src/js/pannellum.js

+ 9
- 3
src/js/pannellum.js Ver arquivo

@@ -598,8 +598,13 @@ function parseGPanoXMP(image, url) {
// Load panorama
panoImage.src = window.URL.createObjectURL(image);
panoImage.onerror = function() {
// If the image fails to load, we check the Content Security Policy
// headers and see if they block loading images as blobs. If they
// do, we load the image directly from the URL. While this should
// allow the image to load, it does prevent parsing of XMP data.
function getCspHeaders() {
if (!window.fetch) return null;
if (!window.fetch)
return null;
return window.fetch(document.location.href)
.then(function(resp){
return resp.headers.get('Content-Security-Policy');
@@ -607,14 +612,15 @@ function parseGPanoXMP(image, url) {
}
getCspHeaders().then(function(cspHeaders) {
if (cspHeaders) {
var invalidImgSource = cspHeaders.split(";").find(function(p){
var invalidImgSource = cspHeaders.split(";").find(function(p) {
var matchstring = p.match(/img-src(.*)/);
if (matchstring) {
return !matchstring[1].includes("blob");
}
});
if (invalidImgSource) {
panoImage.crossOrigin = "anonymous";
console.log('CSP blocks blobs; reverting to URL.');
panoImage.crossOrigin = config.crossOrigin;
panoImage.src = url;
}
}


Carregando…
Cancelar
Salvar