当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Bug in Visual Studio 2015 package.appxmanifest for ms-appx-web in start page?

问题描述:

I'm creating a Javascript Windows 10 Universal app. It complained about using javascript inline with html-- due to having script tags inside my .html file.

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

So I did some research online and it turned out that I could avoid this error by doing two things:

Open package.appxmanifest:

  1. add to start page:

    StartPage="ms-appx-web:///index.html"

  2. Add to package.appxmanifest:

    <uap:ApplicationContentUriRules>

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

(You read this right: we need 3 slashes... ///)

Now this works great and my program is running now without the errors. But I noticed that if I change the start page via the GUI then it can't save it because it complains it's an illegal uri. So the only way I could do this was right-click the package.appxmanifest and choose "view code" and then do it through code. (Actually #2 above can only be done through code).

Maybe someone can clue me in, did I do something wrong? Here's a screenshot doing this through the GUI:

网友答案:

I saw a similar bug has been filed - when use the same uri format in manifest's Content URIs setting, same issue occurs. It's because the there is a rule checks whether the uri has a host. If the uri's host is null or empty, the uri validation fails.

Seems VS team is considering removing this rule, so I think it will be fixed in future release but I cannot say which update will have the fix.

分享给朋友:
您可能感兴趣的文章:
随机阅读: