Bug 1061136 - Assume both http:// and https:// for schemeless URIs in CAPS prefs. r=bz

This commit is contained in:
Bobby Holley 2014-09-05 20:01:06 -07:00
Родитель 0bddd0696f
Коммит 6cfbd9472f
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -1426,7 +1426,15 @@ nsScriptSecurityManager::AddSitesToFileURIWhitelist(const nsCString& aSiteList)
{
// Grab the current site.
bound = SkipUntil<IsWhitespace>(aSiteList, base);
auto site = Substring(aSiteList, base, bound - base);
nsAutoCString site(Substring(aSiteList, base, bound - base));
// Check if the URI is schemeless. If so, add both http and https.
nsAutoCString unused;
if (NS_FAILED(sIOService->ExtractScheme(site, unused))) {
AddSitesToFileURIWhitelist(NS_LITERAL_CSTRING("http://") + site);
AddSitesToFileURIWhitelist(NS_LITERAL_CSTRING("https://") + site);
return;
}
// Convert it to a URI and add it to our list.
nsCOMPtr<nsIURI> uri;

Просмотреть файл

@ -82,11 +82,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=995943
pushPrefs.bind(null, [['capability.policy.policynames', ',somepolicy, someotherpolicy, '],
['capability.policy.somepolicy.checkloaduri.enabled', 'allaccess'],
['capability.policy.someotherpolicy.checkloaduri.enabled', 'nope'],
['capability.policy.somepolicy.sites', ' http://example.org https://example.com'],
['capability.policy.somepolicy.sites', ' http://example.org https://example.com test1.example.com'],
['capability.policy.someotherpolicy.sites', 'http://example.net ']]))
.then(checkLoadFileURI.bind(null, 'http://example.org', true))
.then(checkLoadFileURI.bind(null, 'http://example.com', false))
.then(checkLoadFileURI.bind(null, 'http://example.net', false))
.then(checkLoadFileURI.bind(null, 'http://test1.example.com', true))
.then(checkLoadFileURI.bind(null, 'https://test1.example.com', true))
.then(pushPrefs.bind(null, [['capability.policy.someotherpolicy.checkloaduri.enabled', 'allAccess']]))
.then(checkLoadFileURI.bind(null, 'http://example.net', true))
.then(popPrefs)