当前位置: 首页 > news >正文

html通过使用图像源的协议(protocol)相对 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" /> 

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

编辑 我看到它在使用 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

http://www.lryc.cn/news/185408.html

相关文章:

  • 【SpringBoot】| Thymeleaf 模板引擎
  • Vue Router的进阶
  • 方案:快递站智能视频监控3大亮点汇总
  • Direct3D网格
  • docker安装wiki
  • bigemap在林业勘测规划设计行业的一些应用
  • 设计模式学习
  • Openfire身份认证绕过漏洞
  • 类目体系设计总结
  • gRPC之proto数据验证
  • 计算机竞赛 题目: 基于深度学习的疲劳驾驶检测 深度学习
  • css--踩坑
  • C超市商品信息查询系统
  • 黑马JVM总结(二十七)
  • 软件测试/测试开发丨Python异常处理 学习笔记
  • 026 - STM32学习笔记 - 液晶屏控制(三) - DMA2D快速绘制矩形、直线
  • 【牛客网】OR59 字符串中找出连续最长的数字串
  • 云原生监控系统Prometheus:基于Prometheus构建智能化监控告警系统
  • C++ 学习系列 -- std::list
  • YOLOv8血细胞检测(6):多维协作注意模块MCA | 原创独家创新首发
  • FFmpeg横竖版视频互换背景模糊一键生成
  • Java 华为真题-小朋友分班
  • 机器学习必修课 - 编码分类变量 encoding categorical variables
  • ClickHouse进阶(二十二):clickhouse管理与运维-服务监控
  • Hadoop使用hdfs指令查看hdfs目录的根目录显示被拒
  • [Mac] 安装paddle-pipelines出现 ERROR: Failed building wheel for lmdb
  • LED灯亮灭
  • Acwing.143 最大异或对(trie树)
  • day10.8ubentu流水灯
  • transformer系列5---transformer显存占用分析