<bdo id='ZVufz'></bdo><ul id='ZVufz'></ul>

    1. <i id='ZVufz'><tr id='ZVufz'><dt id='ZVufz'><q id='ZVufz'><span id='ZVufz'><b id='ZVufz'><form id='ZVufz'><ins id='ZVufz'></ins><ul id='ZVufz'></ul><sub id='ZVufz'></sub></form><legend id='ZVufz'></legend><bdo id='ZVufz'><pre id='ZVufz'><center id='ZVufz'></center></pre></bdo></b><th id='ZVufz'></th></span></q></dt></tr></i><div id='ZVufz'><tfoot id='ZVufz'></tfoot><dl id='ZVufz'><fieldset id='ZVufz'></fieldset></dl></div>
    2. <legend id='ZVufz'><style id='ZVufz'><dir id='ZVufz'><q id='ZVufz'></q></dir></style></legend>
    3. <tfoot id='ZVufz'></tfoot>

    4. <small id='ZVufz'></small><noframes id='ZVufz'>

    5. 如何在 Windows 通用应用程序中设置内容安全策略

      时间:2023-09-04

        <i id='KWM68'><tr id='KWM68'><dt id='KWM68'><q id='KWM68'><span id='KWM68'><b id='KWM68'><form id='KWM68'><ins id='KWM68'></ins><ul id='KWM68'></ul><sub id='KWM68'></sub></form><legend id='KWM68'></legend><bdo id='KWM68'><pre id='KWM68'><center id='KWM68'></center></pre></bdo></b><th id='KWM68'></th></span></q></dt></tr></i><div id='KWM68'><tfoot id='KWM68'></tfoot><dl id='KWM68'><fieldset id='KWM68'></fieldset></dl></div>
          <tbody id='KWM68'></tbody>
        <tfoot id='KWM68'></tfoot>
      • <small id='KWM68'></small><noframes id='KWM68'>

            <bdo id='KWM68'></bdo><ul id='KWM68'></ul>

              <legend id='KWM68'><style id='KWM68'><dir id='KWM68'><q id='KWM68'></q></dir></style></legend>

              1. 本文介绍了如何在 Windows 通用应用程序中设置内容安全策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我什至不知道这是否是我需要的,但经过几天 MSDN 论坛帖子 完全没有答案 我想我会试一试在 SO.

                I don't even know if that's what I need, but after several days of this MSDN Forum post with no answers at all I thought I'd give a shot in SO.

                我的问题:我有许多 Windows 8.1 和 Windows Phone 8.1 HTML/Javascripts 应用程序在 <head> 中有一个小的 <script> 句子; 每个 html 页面.我开始将我的应用程序作为单个通用 Windows 应用程序迁移到 Windows 10,但出现以下错误:

                My problem: I have many Windows 8.1 and Windows Phone 8.1 HTML/Javascripts apps that have a little <script> sentence in the <head> of every html page. I started migrating my apps to Windows 10 as a single Universal Windows app but I get the following error:

                CSP14312: Resource violated directive 'script-src ms-appx: data: 'unsafe-eval'' in Host Defined Policy: inline script. Resource will be blocked
                

                当然,什么都没有被执行……我错过了什么吗?

                and of course, nothing gets executed... am I missing anything?

                要重现,只需使用 VS2015 RC 创建一个空白的 Windows 通用应用程序并添加

                edit: To repro just create a blank Windows Universal app with VS2015 RC and add

                <script>
                    console.log('hello');
                </script>
                

                就在 head 标签关闭之前

                right before the head tag closes

                推荐答案

                Rob 说得对,默认情况下你不能在 ms-appx:/// 协议中使用内联脚本.这是应用程序的默认协议,并且具有不允许内联脚本的默认 CSP 策略.

                Rob has it right, by default you can't have inline script in ms-appx:/// protocol. This is the default protocol for an application and has a default CSP policy that doesn't allow inline script.

                如果您真的希望使用内联脚本,您可以通过 ms-appx-web:/// 协议导航到没有默认 CSP 策略的内容.

                If you really wish to use inline script you can navigate to the content via ms-appx-web:/// protocol where there is no default CSP policy.

                需要注意的是,您无权访问此协议中的某些功能.

                The one note is that you do not have access to some capabilities in this protocol.

                除了 Rob 所说的之外,我唯一的区别是您很可能希望像这样设置应用程序内容 URI 规则 (ACUR)

                The only difference I have beyond what Rob said is that you most likely want to set the Application Content URI Rule (ACUR) like this

                <uap:ApplicationContentUriRules>
                   <uap:Rule Type="include" Match ="ms-appx-web:///" WindowsRuntimeAccess="all"/>
                </uap:ApplicationContentUriRules>
                

                要导航到您的内容,您可以将清单中的 StartPage 设置为 ms-appx-web:///default.html

                To navigate to your content you can set the StartPage in the manifest to ms-appx-web:///default.html

                这篇关于如何在 Windows 通用应用程序中设置内容安全策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:你能检测到“平板电脑模式"吗?在 Windows 10 上 下一篇:如何解决 Windows 10 上的“node-gyp 重建"问题?

                相关文章

                最新文章

              2. <tfoot id='WUNEI'></tfoot>
                1. <small id='WUNEI'></small><noframes id='WUNEI'>

                  <i id='WUNEI'><tr id='WUNEI'><dt id='WUNEI'><q id='WUNEI'><span id='WUNEI'><b id='WUNEI'><form id='WUNEI'><ins id='WUNEI'></ins><ul id='WUNEI'></ul><sub id='WUNEI'></sub></form><legend id='WUNEI'></legend><bdo id='WUNEI'><pre id='WUNEI'><center id='WUNEI'></center></pre></bdo></b><th id='WUNEI'></th></span></q></dt></tr></i><div id='WUNEI'><tfoot id='WUNEI'></tfoot><dl id='WUNEI'><fieldset id='WUNEI'></fieldset></dl></div>
                      <bdo id='WUNEI'></bdo><ul id='WUNEI'></ul>

                    <legend id='WUNEI'><style id='WUNEI'><dir id='WUNEI'><q id='WUNEI'></q></dir></style></legend>