|
|
|
|
| 44 |
#include "nsNetUtil.h" |
44 |
#include "nsNetUtil.h" |
| 45 |
#include "nsInt64.h" |
45 |
#include "nsInt64.h" |
| 46 |
#include "nsEscape.h" |
46 |
#include "nsEscape.h" |
|
|
47 |
#include "nsIPrefService.h" |
| 48 |
#include "nsIPrefBranch.h" |
| 47 |
|
49 |
|
| 48 |
#include "nsIScriptSecurityManager.h" |
50 |
#include "nsIScriptSecurityManager.h" |
| 49 |
#include "nsIPrincipal.h" |
51 |
#include "nsIPrincipal.h" |
|
Lines 222-227
nsJARChannel::nsJARChannel()
|
Link Here
|
|---|
|
| 222 |
, mLoadFlags(LOAD_NORMAL) |
224 |
, mLoadFlags(LOAD_NORMAL) |
| 223 |
, mStatus(NS_OK) |
225 |
, mStatus(NS_OK) |
| 224 |
, mIsPending(PR_FALSE) |
226 |
, mIsPending(PR_FALSE) |
|
|
227 |
, mIsUnsafe(PR_TRUE) |
| 225 |
, mJarInput(nsnull) |
228 |
, mJarInput(nsnull) |
| 226 |
{ |
229 |
{ |
| 227 |
#if defined(PR_LOGGING) |
230 |
#if defined(PR_LOGGING) |
|
Lines 323-328
nsJARChannel::EnsureJarInput(PRBool bloc
|
Link Here
|
|---|
|
| 323 |
} |
326 |
} |
| 324 |
|
327 |
|
| 325 |
if (mJarFile) { |
328 |
if (mJarFile) { |
|
|
329 |
mIsUnsafe = PR_FALSE; |
| 330 |
|
| 326 |
// NOTE: we do not need to deal with mSecurityInfo here, |
331 |
// NOTE: we do not need to deal with mSecurityInfo here, |
| 327 |
// because we're loading from a local file |
332 |
// because we're loading from a local file |
| 328 |
rv = CreateJarInput(gJarHandler->JarCache()); |
333 |
rv = CreateJarInput(gJarHandler->JarCache()); |
|
Lines 337-343
nsJARChannel::EnsureJarInput(PRBool bloc
|
Link Here
|
|---|
|
| 337 |
if (NS_SUCCEEDED(rv)) |
342 |
if (NS_SUCCEEDED(rv)) |
| 338 |
rv = NS_OpenURI(mDownloader, nsnull, mJarBaseURI, nsnull, |
343 |
rv = NS_OpenURI(mDownloader, nsnull, mJarBaseURI, nsnull, |
| 339 |
mLoadGroup, mCallbacks, |
344 |
mLoadGroup, mCallbacks, |
| 340 |
mLoadFlags & ~LOAD_DOCUMENT_URI); |
345 |
mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS)); |
| 341 |
} |
346 |
} |
| 342 |
return rv; |
347 |
return rv; |
| 343 |
|
348 |
|
|
Lines 644-649
nsJARChannel::Open(nsIInputStream **stre
|
Link Here
|
|---|
|
| 644 |
NS_ENSURE_TRUE(!mJarInput, NS_ERROR_IN_PROGRESS); |
649 |
NS_ENSURE_TRUE(!mJarInput, NS_ERROR_IN_PROGRESS); |
| 645 |
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); |
650 |
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); |
| 646 |
|
651 |
|
|
|
652 |
mJarFile = nsnull; |
| 653 |
mIsUnsafe = PR_TRUE; |
| 654 |
|
| 647 |
nsresult rv = EnsureJarInput(PR_TRUE); |
655 |
nsresult rv = EnsureJarInput(PR_TRUE); |
| 648 |
if (NS_FAILED(rv)) return rv; |
656 |
if (NS_FAILED(rv)) return rv; |
| 649 |
|
657 |
|
|
Lines 666-671
nsJARChannel::AsyncOpen(nsIStreamListene
|
Link Here
|
|---|
|
| 666 |
NS_ENSURE_ARG_POINTER(listener); |
674 |
NS_ENSURE_ARG_POINTER(listener); |
| 667 |
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); |
675 |
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); |
| 668 |
|
676 |
|
|
|
677 |
mJarFile = nsnull; |
| 678 |
mIsUnsafe = PR_TRUE; |
| 679 |
|
| 669 |
// Initialize mProgressSink |
680 |
// Initialize mProgressSink |
| 670 |
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink); |
681 |
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink); |
| 671 |
|
682 |
|
|
Lines 687-692
nsJARChannel::AsyncOpen(nsIStreamListene
|
Link Here
|
|---|
|
| 687 |
mListener = listener; |
698 |
mListener = listener; |
| 688 |
mListenerContext = ctx; |
699 |
mListenerContext = ctx; |
| 689 |
mIsPending = PR_TRUE; |
700 |
mIsPending = PR_TRUE; |
|
|
701 |
return NS_OK; |
| 702 |
} |
| 703 |
|
| 704 |
//----------------------------------------------------------------------------- |
| 705 |
// nsIJARChannel |
| 706 |
//----------------------------------------------------------------------------- |
| 707 |
NS_IMETHODIMP |
| 708 |
nsJARChannel::GetIsUnsafe(PRBool *isUnsafe) |
| 709 |
{ |
| 710 |
*isUnsafe = mIsUnsafe; |
| 690 |
return NS_OK; |
711 |
return NS_OK; |
| 691 |
} |
712 |
} |
| 692 |
|
713 |
|
|
Lines 729-734
nsJARChannel::OnDownloadComplete(nsIDown
|
Link Here
|
|---|
|
| 729 |
} |
750 |
} |
| 730 |
status = rv; |
751 |
status = rv; |
| 731 |
} |
752 |
} |
|
|
753 |
|
| 754 |
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); |
| 755 |
if (httpChannel) { |
| 756 |
// We only want to run scripts if the server really intended to |
| 757 |
// send us a JAR file. Check the server-supplied content type for |
| 758 |
// a JAR type. |
| 759 |
nsCAutoString header; |
| 760 |
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"), |
| 761 |
header); |
| 762 |
|
| 763 |
nsCAutoString contentType; |
| 764 |
nsCAutoString charset; |
| 765 |
NS_ParseContentType(header, contentType, charset); |
| 766 |
|
| 767 |
mIsUnsafe = !contentType.EqualsLiteral("application/java-archive") && |
| 768 |
!contentType.EqualsLiteral("application/x-jar"); |
| 769 |
} else { |
| 770 |
nsCOMPtr<nsIJARChannel> innerJARChannel(do_QueryInterface(channel)); |
| 771 |
if (innerJARChannel) { |
| 772 |
PRBool unsafe; |
| 773 |
innerJARChannel->GetIsUnsafe(&unsafe); |
| 774 |
mIsUnsafe = unsafe; |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
|
| 779 |
if (mIsUnsafe) { |
| 780 |
PRBool allowUnpack = PR_FALSE; |
| 781 |
|
| 782 |
nsCOMPtr<nsIPrefBranch> prefs = |
| 783 |
do_GetService(NS_PREFSERVICE_CONTRACTID); |
| 784 |
if (prefs) { |
| 785 |
prefs->GetBoolPref("network.jar.open-unsafe-types", &allowUnpack); |
| 786 |
} |
| 787 |
|
| 788 |
if (!allowUnpack) { |
| 789 |
status = NS_ERROR_FAILURE; |
| 790 |
} |
| 732 |
} |
791 |
} |
| 733 |
|
792 |
|
| 734 |
if (NS_SUCCEEDED(status)) { |
793 |
if (NS_SUCCEEDED(status)) { |
|
Lines 745-750
nsJARChannel::OnDownloadComplete(nsIDown
|
Link Here
|
|---|
|
| 745 |
} |
804 |
} |
| 746 |
|
805 |
|
| 747 |
if (NS_FAILED(status)) { |
806 |
if (NS_FAILED(status)) { |
|
|
807 |
mStatus = status; |
| 748 |
OnStartRequest(nsnull, nsnull); |
808 |
OnStartRequest(nsnull, nsnull); |
| 749 |
OnStopRequest(nsnull, nsnull, status); |
809 |
OnStopRequest(nsnull, nsnull, status); |
| 750 |
} |
810 |
} |