微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/html/230605.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐