5

phonegap/callback/cordova 在所有平台上都有白名单吗?它的实施方式是否相同?

4

1 回答 1

16

白名单在 iOS 和 Android 上都有,但在其他平台上还没有。

iOS下,它位于“外部主机”的名称下,此处解释:http ://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

Q. Links to and imported files from external hosts don't load?
A. The latest code has the new white-list feature. If you are 
referencing external hosts, you will have to add the host in PhoneGap.plist 
under the "ExternalHosts" key. Wildcards are ok. So if you are connecting to
"http://phonegap.com", you have to add "phonegap.com" to the list (or use the 
wildcard "*.phonegap.com" which will match subdomains as well).

例如:

<key>ExternalHosts</key>
<array>
    <string>*</string>
</array>


对于Android,该功能目前未记录在案并且有些错误,尽管正在修复中。此线程包含一些很好的故障排除详细信息:https ://groups.google.com/forum/#!topic/phonegap/9NZ4J4l1I-s

简而言之,它是 xml/phonegap.xml 中的“访问”属性。它使用 perl 风格的正则表达式

To allow all domains (debugging): <access origin=".*"/> 

很快,这可能会更改为以下语法:

<access origin="https://example.com" subdomains="true" />


BlackBerry上的 白名单作为 WebWorks 框架的一部分提供,并通过 config.xml 进行配置:

https://bdsc.webapps.blackberry.com/html5/documentation/ww_developing/access_element_834677_11.html

示例项目允许通过“*”通配符访问所有 URL。

于 2012-01-17T18:20:26.420 回答