fixes bug 290982 "Disallow viewsource:javascript and jar:viewsource URLs" r=dveditz sr=jst a=dbaron

This commit is contained in:
darin%meer.net 2005-05-12 15:20:43 +00:00
Родитель 7a9bbdda84
Коммит 8c2929e38d
2 изменённых файлов: 27 добавлений и 0 удалений

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

@ -227,6 +227,22 @@ nsJARChannel::Init(nsIURI *uri)
{ {
nsresult rv; nsresult rv;
mJarURI = do_QueryInterface(uri, &rv); mJarURI = do_QueryInterface(uri, &rv);
if (NS_FAILED(rv))
return rv;
// Prevent loading jar:javascript URIs (see bug 290982).
nsCOMPtr<nsIURI> innerURI;
rv = mJarURI->GetJARFile(getter_AddRefs(innerURI));
if (NS_FAILED(rv))
return rv;
PRBool isJS;
rv = innerURI->SchemeIs("javascript", &isJS);
if (NS_FAILED(rv))
return rv;
if (isJS) {
NS_WARNING("blocking jar:javascript:");
return NS_ERROR_INVALID_ARG;
}
#if defined(PR_LOGGING) #if defined(PR_LOGGING)
mJarURI->GetSpec(mSpec); mJarURI->GetSpec(mSpec);

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

@ -80,6 +80,17 @@ nsViewSourceChannel::Init(nsIURI* uri)
nsCOMPtr<nsIIOService> pService(do_GetIOService(&rv)); nsCOMPtr<nsIIOService> pService(do_GetIOService(&rv));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCAutoString scheme;
rv = pService->ExtractScheme(path, scheme);
if (NS_FAILED(rv))
return rv;
// prevent viewing source of javascript URIs (see bug 204779)
if (scheme.LowerCaseEqualsLiteral("javascript")) {
NS_WARNING("blocking view-source:javascript:");
return NS_ERROR_INVALID_ARG;
}
rv = pService->NewChannel(path, nsnull, nsnull, getter_AddRefs(mChannel)); rv = pService->NewChannel(path, nsnull, nsnull, getter_AddRefs(mChannel));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;