Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 288536 Details for
Bug 369814
[patch]
naming fixes
jar-require-content-type.diff (text/plain), 8.43 KB, created by
Dave Camp (:dcamp)
(
hide
)
Description:
naming fixes
Filename:
MIME Type:
Creator:
Dave Camp (:dcamp)
Size:
8.43 KB
patch
obsolete
>diff --git a/docshell/base/Makefile.in b/docshell/base/Makefile.in >--- a/docshell/base/Makefile.in >+++ b/docshell/base/Makefile.in >@@ -85,6 +85,7 @@ REQUIRES = xpcom \ > windowwatcher \ > imglib2 \ > mimetype \ >+ jar \ > $(NULL) > > SDK_XPIDLSRCS = \ >diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp >--- a/docshell/base/nsDocShell.cpp >+++ b/docshell/base/nsDocShell.cpp >@@ -168,6 +168,8 @@ > > #include "nsITextToSubURI.h" > >+#include "nsIJARChannel.h" >+ > #include "prlog.h" > #include "prmem.h" > >@@ -1291,12 +1293,38 @@ nsDocShell::SetDocumentCharsetInfo(nsIDo > return NS_OK; > } > >+ >+nsresult >+nsDocShell::ChannelIsUnsafe(PRBool *aUnsafe) >+{ >+ *aUnsafe = PR_FALSE; >+ >+ nsCOMPtr<nsIChannel> channel; >+ GetCurrentDocumentChannel(getter_AddRefs(channel)); >+ if (!channel) { >+ return NS_OK; >+ } >+ >+ nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(channel); >+ if (!jarChannel) { >+ return NS_OK; >+ } >+ >+ return jarChannel->GetIsUnsafe(aUnsafe); >+} >+ > NS_IMETHODIMP > nsDocShell::GetAllowPlugins(PRBool * aAllowPlugins) > { > NS_ENSURE_ARG_POINTER(aAllowPlugins); > > *aAllowPlugins = mAllowPlugins; >+ if (!mAllowPlugins) { >+ return NS_OK; >+ } >+ >+ PRBool unsafe; >+ *aAllowPlugins = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe; > return NS_OK; > } > >@@ -1314,6 +1342,12 @@ nsDocShell::GetAllowJavascript(PRBool * > NS_ENSURE_ARG_POINTER(aAllowJavascript); > > *aAllowJavascript = mAllowJavascript; >+ if (!mAllowJavascript) { >+ return NS_OK; >+ } >+ >+ PRBool unsafe; >+ *aAllowJavascript = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe; > return NS_OK; > } > >@@ -1329,6 +1363,12 @@ NS_IMETHODIMP nsDocShell::GetAllowMetaRe > NS_ENSURE_ARG_POINTER(aReturn); > > *aReturn = mAllowMetaRedirects; >+ if (!mAllowMetaRedirects) { >+ return NS_OK; >+ } >+ >+ PRBool unsafe; >+ *aReturn = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe; > return NS_OK; > } > >diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h >--- a/docshell/base/nsDocShell.h >+++ b/docshell/base/nsDocShell.h >@@ -513,7 +513,10 @@ protected: > > // Check whether aURI is about:blank > static PRBool IsAboutBlank(nsIURI* aURI); >- >+ >+ // Check for a suspicious channel (such as a JAR channel where the >+ // server-returned content type isn't a known JAR type) >+ nsresult ChannelIsUnsafe(PRBool *aUnsafe); > protected: > // Override the parent setter from nsDocLoader > virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader); >diff --git a/modules/libjar/nsIJARChannel.idl b/modules/libjar/nsIJARChannel.idl >--- a/modules/libjar/nsIJARChannel.idl >+++ b/modules/libjar/nsIJARChannel.idl >@@ -37,7 +37,14 @@ > > #include "nsIChannel.idl" > >-[scriptable, uuid(c7e410d1-85f2-11d3-9f63-006008a6efe9)] >+[scriptable, uuid(6e6cc56d-51eb-4299-a795-dcfd1229ab3d)] > interface nsIJARChannel : nsIChannel > { >+ /** >+ * Returns TRUE if the JAR file is not safe (if the content type reported >+ * by the server for a remote JAR is not of an expected type). Scripting, >+ * redirects, and plugins should be disabled when loading from this >+ * channel. >+ */ >+ readonly attribute boolean isUnsafe; > }; >diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp >--- a/modules/libjar/nsJARChannel.cpp >+++ b/modules/libjar/nsJARChannel.cpp >@@ -44,6 +44,8 @@ > #include "nsNetUtil.h" > #include "nsInt64.h" > #include "nsEscape.h" >+#include "nsIPrefService.h" >+#include "nsIPrefBranch.h" > > #include "nsIScriptSecurityManager.h" > #include "nsIPrincipal.h" >@@ -222,6 +224,7 @@ nsJARChannel::nsJARChannel() > , mLoadFlags(LOAD_NORMAL) > , mStatus(NS_OK) > , mIsPending(PR_FALSE) >+ , mIsUnsafe(PR_TRUE) > , mJarInput(nsnull) > { > #if defined(PR_LOGGING) >@@ -323,6 +326,8 @@ nsJARChannel::EnsureJarInput(PRBool bloc > } > > if (mJarFile) { >+ mIsUnsafe = PR_FALSE; >+ > // NOTE: we do not need to deal with mSecurityInfo here, > // because we're loading from a local file > rv = CreateJarInput(gJarHandler->JarCache()); >@@ -337,7 +342,7 @@ nsJARChannel::EnsureJarInput(PRBool bloc > if (NS_SUCCEEDED(rv)) > rv = NS_OpenURI(mDownloader, nsnull, mJarBaseURI, nsnull, > mLoadGroup, mCallbacks, >- mLoadFlags & ~LOAD_DOCUMENT_URI); >+ mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS)); > } > return rv; > >@@ -644,6 +649,9 @@ nsJARChannel::Open(nsIInputStream **stre > NS_ENSURE_TRUE(!mJarInput, NS_ERROR_IN_PROGRESS); > NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); > >+ mJarFile = nsnull; >+ mIsUnsafe = PR_TRUE; >+ > nsresult rv = EnsureJarInput(PR_TRUE); > if (NS_FAILED(rv)) return rv; > >@@ -666,6 +674,9 @@ nsJARChannel::AsyncOpen(nsIStreamListene > NS_ENSURE_ARG_POINTER(listener); > NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); > >+ mJarFile = nsnull; >+ mIsUnsafe = PR_TRUE; >+ > // Initialize mProgressSink > NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink); > >@@ -687,6 +698,16 @@ nsJARChannel::AsyncOpen(nsIStreamListene > mListener = listener; > mListenerContext = ctx; > mIsPending = PR_TRUE; >+ return NS_OK; >+} >+ >+//----------------------------------------------------------------------------- >+// nsIJARChannel >+//----------------------------------------------------------------------------- >+NS_IMETHODIMP >+nsJARChannel::GetIsUnsafe(PRBool *isUnsafe) >+{ >+ *isUnsafe = mIsUnsafe; > return NS_OK; > } > >@@ -729,6 +750,44 @@ nsJARChannel::OnDownloadComplete(nsIDown > } > status = rv; > } >+ >+ nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); >+ if (httpChannel) { >+ // We only want to run scripts if the server really intended to >+ // send us a JAR file. Check the server-supplied content type for >+ // a JAR type. >+ nsCAutoString header; >+ httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"), >+ header); >+ >+ nsCAutoString contentType; >+ nsCAutoString charset; >+ NS_ParseContentType(header, contentType, charset); >+ >+ mIsUnsafe = !contentType.EqualsLiteral("application/java-archive") && >+ !contentType.EqualsLiteral("application/x-jar"); >+ } else { >+ nsCOMPtr<nsIJARChannel> innerJARChannel(do_QueryInterface(channel)); >+ if (innerJARChannel) { >+ PRBool unsafe; >+ innerJARChannel->GetIsUnsafe(&unsafe); >+ mIsUnsafe = unsafe; >+ } >+ } >+ } >+ >+ if (mIsUnsafe) { >+ PRBool allowUnpack = PR_FALSE; >+ >+ nsCOMPtr<nsIPrefBranch> prefs = >+ do_GetService(NS_PREFSERVICE_CONTRACTID); >+ if (prefs) { >+ prefs->GetBoolPref("network.jar.open-unsafe-types", &allowUnpack); >+ } >+ >+ if (!allowUnpack) { >+ status = NS_ERROR_FAILURE; >+ } > } > > if (NS_SUCCEEDED(status)) { >@@ -745,6 +804,7 @@ nsJARChannel::OnDownloadComplete(nsIDown > } > > if (NS_FAILED(status)) { >+ mStatus = status; > OnStartRequest(nsnull, nsnull); > OnStopRequest(nsnull, nsnull, status); > } >diff --git a/modules/libjar/nsJARChannel.h b/modules/libjar/nsJARChannel.h >--- a/modules/libjar/nsJARChannel.h >+++ b/modules/libjar/nsJARChannel.h >@@ -97,7 +97,8 @@ private: > PRInt32 mContentLength; > PRUint32 mLoadFlags; > nsresult mStatus; >- PRBool mIsPending; >+ PRPackedBool mIsPending; >+ PRPackedBool mIsUnsafe; > > nsJARInputThunk *mJarInput; > nsCOMPtr<nsIStreamListener> mDownloader; >diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js >--- a/modules/libpref/src/init/all.js >+++ b/modules/libpref/src/init/all.js >@@ -612,6 +612,11 @@ pref("network.http.pipelining.maxrequest > pref("network.http.pipelining.maxrequests" , 4); > > // </http> >+ >+// If false, remote JAR files that are served with a content type other than >+// application/java-archive or application/x-jar will not be opened >+// by the jar channel. >+pref("network.jar.open-unsafe-types", false); > > // This preference controls whether or not internationalized domain names (IDN) > // are handled. IDN requires a nsIIDNService implementation.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 369814
:
287901
|
288030
|
288233
|
288383
|
288428
|
288536
|
288538
|
288598
|
288609
|
288615
|
288623
|
288634
|
288662
|
288666
|
288695
|
288772
|
289040
|
289041
|
289242
|
289243
|
290297
|
290344
|
306279
|
306280