试图从带有URL () 的框架中加载URL (),存在风险。

huangapple go评论89阅读模式
英文:

<track> Unsafe attempt to load URL () from frame with URL ()

问题

watch.html:1 尝试从 URL file:///C:/subtitle.vtt 加载时存在不安全的行为,来源为 URL file:///C:/watch.html。'file:' URL 被视为唯一的安全来源。

这是我在Chrome浏览器控制台中尝试将字幕添加到视频时遇到的错误。在Internet Explorer中,字幕可以正常工作,没有任何错误消息。我运行的代码是:

<video controls>
<source src="C:\video.mp4" type="video/mp4">
<track src="C:\subtitle.vtt" kind="subtitles" srclang="en" label="English">
</video>
英文:
watch.html:1 Unsafe attempt to load URL file:///C:/subtitle.vtt from frame with URL file:///C:/watch.html. &#39;file:&#39; URLs are treated as unique security origins.

This is the error I get in Chrome's console when attempting to add the subtitle to the video. The subtitle is working on Internet Explorer without any error message. The code I'm running:

&lt;video controls&gt;
&lt;source src=&quot;C:\video.mp4&quot; type=&quot;video/mp4&quot;&gt;
&lt;track src=&quot;C:\subtitle.vtt&quot; kind=&quot;subtitles&quot; srclang=&quot;en&quot; label=&quot;English&quot;&gt;
&lt;/video&gt;

答案1

得分: 3

解决方案:视频和字幕文件应该在相同的路径下!

英文:

Solution: The video and subtitle file should be in the same path!

答案2

得分: 0

根据我的理解CORSRequestNotHttp

加载本地文件

来自同一目录及其子目录的本地文件在历史上被视为来自相同的源。这意味着在测试期间,可以从本地目录或子目录加载文件及其所有资源,而不会触发CORS错误。

不幸的是,这带来了安全性问题,正如在这份安全公告中所指出的:CVE-2019-11730。许多浏览器,包括Firefox和Chrome,现在默认将所有本地文件视为具有不透明的来源。因此,加载包括本地资源的本地文件现在会导致CORS错误。

今天唯一的修复方法是设置本地服务器:

需要进行本地测试的开发人员现在应该设置本地服务器。由于所有文件都从相同的方案和域(localhost)提供,它们都具有相同的源,不会触发跨源错误。

英文:

To my understanding of CORSRequestNotHttp:

> <h3>Loading a local file</h3>
>
> Local files from the same directory and subdirectories were
> historically treated as being from the same origin. This meant that a
> file and all its resources could be loaded from a local directory or
> subdirectory during testing, without triggering a CORS error.
>
> Unfortunately this had security implications, as noted in this
> advisory: CVE-2019-11730. Many browsers, including Firefox and Chrome,
> now treat all local files as having opaque origins (by default). As a
> result, loading a local file with included local resources will now
> result in CORS errors.

The only fix today is to set up a local server:

> Developers who need to perform local testing should now set up a local
> server. As all files are served from the same scheme and domain
> (localhost) they all have the same origin, and do not trigger
> cross-origin errors.

huangapple
  • 本文由 发表于 2020年1月4日 00:16:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581827.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定