Firefox跨域图像被污染 [英] Firefox Cross Domain images are tainted

查看:134
本文介绍了Firefox跨域图像被污染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在Chrome中有效,但不在Firefox中。 Access-Control-Allow-Origin设置为*,并且将crossOrigin设置为匿名加载图像,但是当将图像绘制到firefox中的画布上时,它们会污染画布。加载图像的代码如下:

This is working in Chrome, but not in firefox. The Access-Control-Allow-Origin is set to *, and images are loaded with a crossOrigin set to anonymous, however when drawing the images onto a canvas in firefox they taint the canvas. The code to load the image is as follows:

var image = new Image();
image.onload = loadCallback;
image.crossOrigin = "anonymous";
image.src = imageSrc;

几个问题:


  1. 有没有我缺少的是特定于Firefox的东西?是否需要比Access-Control-Allow-Origin更多的标题?

  2. 是否有任何方法从加载的图片确定它是污染的(对调试有用)。

  3. 服务器的域名是相同的,它们只是不同的子域(ie images.example.com和mysite.example.com),是否有任何方式使用这个我的优势或应该我真的有一个代理来做一个passthru,只是忘了处理CORS问题?


推荐答案

在Firefox 9中添加了支持启用CORS的图片时不支持画布。请参阅 https://bugzilla.mozilla.org/show_bug.cgi?id=685518

Support for not tainting the canvas when CORS-enabled images are painted to it was added in Firefox 9. See https://bugzilla.mozilla.org/show_bug.cgi?id=685518

因此,如果您使用Firefox 8进行测试,它不会工作。尝试使用Firefox 9测试版?

So if you're testing with Firefox 8, it won't work. Try a Firefox 9 beta?

这篇关于Firefox跨域图像被污染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆