зеркало из https://github.com/mozilla/pjs.git
fixes bug 290982 "Disallow viewsource:javascript and jar:viewsource URLs" r=dveditz sr=jst a=dbaron
This commit is contained in:
Родитель
7a9bbdda84
Коммит
8c2929e38d
|
@ -227,6 +227,22 @@ nsJARChannel::Init(nsIURI *uri)
|
|||
{
|
||||
nsresult 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)
|
||||
mJarURI->GetSpec(mSpec);
|
||||
|
|
|
@ -80,6 +80,17 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
|||
nsCOMPtr<nsIIOService> pService(do_GetIOService(&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));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче