角度变化的URL"不安全:"在扩展页面 [英] Angular changes urls to "unsafe:" in extension page

查看:197
本文介绍了角度变化的URL"不安全:"在扩展页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的角度与应用程序的列表,而且每一个都是看到更详细的应用程序的链接(应用程序/ app.id):

I am trying to use angular with a list of apps, and each one is a link to see an app in more detail (apps/app.id):

<a id="{{app.id}}" href="apps/{{app.id}}" >{{app.name}}</a>

我每次点击其中一个链接,浏览器显示的URL为不安全:镀扩展://kpbipnfncdpgejhmdneaagc...../apps/app.id

Every time I click on one of these links, Chrome shows the URL as unsafe:chrome-extension://kpbipnfncdpgejhmdneaagc...../apps/app.id

在什么地方的不安全从何而来?

Where does the unsafe come from?

推荐答案

您需要使用常规的前pression明确添加URL协议角的白名单中。只有 HTTP HTTPS FTP 的mailto 默认情况下启用。角意志preFIX非白名单网址不安全:使用的协议,如铬扩展时

You need to explicitly add URL protocols to Angular's whitelist using a regular expression. Only http, https, ftp and mailto are enabled by default. Angular will prefix a non-whitelisted URL with unsafe: when using a protocol such as chrome-extension:.

一个好地方,白名单的铬扩展:的协议将是你的模块的配置块:

A good place to whitelist the chrome-extension: protocol would be in your module's config block:

var app = angular.module( 'myApp', [] )
.config( [
    '$compileProvider',
    function( $compileProvider )
    {   
        $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);
        // Angular before v1.2 uses $compileProvider.urlSanitizationWhitelist(...)
    }
]);

同样的程序也适用于当你需要使用的协议,如文件:电话:

请参见AngularJS $ compileProvider API文档了解更多信息。

Please see the AngularJS $compileProvider API documentation for more info.

这篇关于角度变化的URL&QUOT;不安全:&QUOT;在扩展页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆