【发布时间】:2021-07-24 03:33:22
【问题描述】:
我正在使用以下内容来使用带有 JPG 后备的 WebP 图像:
<img
src="{{ $img_webp_desktop.RelPermalink }}"
onerror="this.onerror=null;this.src='{{ $img_jpg_desktop.RelPermalink }}';"
loading="lazy"
height="{{ $img_jpg_desktop.Height }}"
width="{{ $img_jpg_desktop.Width }}">
但是,当我的 CSP 设置为 script-src 'self' 时,onerror 内联脚本不会被执行并且回退不起作用。
有什么方法可以让 CSP 工作?最坏的情况,我可以启用unsafe-hashes。
提前致谢:)
【问题讨论】:
标签: html content-security-policy hugo