html – 通过使用图像源的协议相对URL来防止安全/不安全的错误

有人知道使用 protocol relative URLs作为图像源是否有问题可以防止混合内容安全警告.

例如链接图像:

<img src="//domain.com/img.jpg" />

代替:

<img src="http://domain.com/img.jpg" />
or
<img src="https//domain.com/img.jpg" />

在我的测试中,我没有看到任何建议这是错误的,但我不知道如果它有边缘的情况下会造成问题.

编辑我看到它使用PHPgetimagesize功能时丢失错误.

解决方法

找到一个有趣的getcha来使用协议相对URL:

You have to be careful to only use
this Syntax in pages destined for
browsers. If you put it in an email,
there will be no base page URL to use
in resolving the relative URL. In
Outlook at least,this URL will be
interpreted as a Windows network file,
not what you intended.

here

本质上,只要请求是由浏览器而不是外部电子邮件客户端,这不是有效的原因.

更多信息从here

A relative URL without a scheme (http:
or https:) is valid,per RTF 3986:
Section 4.2. If a client chokes on it,
then it’s the client’s fault because
they’re not complying with the URI
Syntax specified in the RFC.

Your example is valid and should work. I’ve used that relative URL method myself on heavily trafficked sites and have had zero complaints. Also,we test our sites in Firefox,Safari,IE6,IE7 and Opera. These browsers all understand that URL format

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些