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

有人知道使用 protocol relative URLs 是否有问题吗?用于图像源以防止混合内容安全警告。

例如链接一张图片:

html 复制代码
<img src="//domain.com/img.jpg" /> 

代替:

html 复制代码
<img src="http://domain.com/img.jpg" /> 
or 
<img src="https//domain.com/img.jpg" /> 

在我的测试中,我没有看到任何迹象表明这是错误的,但我不确定它是否存在会产生问题的边缘情况。

编辑 我看到它在使用 PHP 的 getimagesize 时抛出错误功能。

请您参考如下方法:

在使用协议(protocol)相对 URL 时发现了一个有趣的问题:

ou 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

相关推荐
小张同学a.12 分钟前
OpenStack 私有云实战 2—— Glance 镜像与 Nova 计算服务搭建
linux·运维·服务器·openstack
xiaoye-duck32 分钟前
《Linux网络编程》TCP 网络编程(下):基于 TCP 多线程通用字典服务 + 远程命令执行实战
linux·服务器·tcp/ip
2401_894915533 小时前
GEO 优化源码全解析:从搜索引擎到 AI 引擎的底层改写逻辑
java·服务器·前端·数据库·人工智能·分布式·搜索引擎
rockey6278 小时前
C#脚本引擎之AScript与Jurassic、Jint对比
javascript·c#·.net·js·script·动态脚本
huainingning8 小时前
R4930-G7服务器(RAID-LSI-9560-LP-8i-4GB)网页方式做Raid方法
服务器
lzhdim9 小时前
12、JavaScript常见的内存泄露问题 - JavaScript学习系列文章
开发语言·前端·javascript·学习·ecmascript
小杨不想秃头11 小时前
信息安全工程师教程第二章密码学
运维·服务器·密码学
I'mChloe11 小时前
WGCLOUD怎么监控多台服务器?从Server、Agent 部署到监控面板实战
运维·服务器
Android系统攻城狮11 小时前
Linux PipeWire深度解析之pw_init调用流程与实战(八十三)
linux·运维·服务器·音频进阶·pipewire音频进阶
zbyyd13 小时前
Linux 进程管理详解:从概念到实战
linux·运维·服务器