Attachment #288536: naming fixes for bug #369814

View | Details | Raw Unified | Return to bug 369814
Collapse All | Expand All

(-)a/docshell/base/Makefile.in (+1 lines)
Line     Link Here 
 Lines 85-90   REQUIRES = xpcom \ Link Here 
85
		  windowwatcher \
85
		  windowwatcher \
86
		  imglib2 \
86
		  imglib2 \
87
		  mimetype \
87
		  mimetype \
88
		  jar \
88
		  $(NULL)
89
		  $(NULL)
89
90
90
SDK_XPIDLSRCS = \
91
SDK_XPIDLSRCS = \
(-)a/docshell/base/nsDocShell.cpp (+40 lines)
Line     Link Here 
 Lines 168-173    Link Here 
168
168
169
#include "nsITextToSubURI.h"
169
#include "nsITextToSubURI.h"
170
170
171
#include "nsIJARChannel.h"
172
171
#include "prlog.h"
173
#include "prlog.h"
172
#include "prmem.h"
174
#include "prmem.h"
173
175
 Lines 1291-1302   nsDocShell::SetDocumentCharsetInfo(nsIDo Link Here 
1291
    return NS_OK;
1293
    return NS_OK;
1292
}
1294
}
1293
1295
1296
1297
nsresult
1298
nsDocShell::ChannelIsUnsafe(PRBool *aUnsafe)
1299
{
1300
    *aUnsafe = PR_FALSE;
1301
1302
    nsCOMPtr<nsIChannel> channel;
1303
    GetCurrentDocumentChannel(getter_AddRefs(channel));
1304
    if (!channel) {
1305
        return NS_OK;
1306
    }
1307
1308
    nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(channel);
1309
    if (!jarChannel) {
1310
        return NS_OK;
1311
    }
1312
1313
    return jarChannel->GetIsUnsafe(aUnsafe);
1314
}
1315
1294
NS_IMETHODIMP
1316
NS_IMETHODIMP
1295
nsDocShell::GetAllowPlugins(PRBool * aAllowPlugins)
1317
nsDocShell::GetAllowPlugins(PRBool * aAllowPlugins)
1296
{
1318
{
1297
    NS_ENSURE_ARG_POINTER(aAllowPlugins);
1319
    NS_ENSURE_ARG_POINTER(aAllowPlugins);
1298
1320
1299
    *aAllowPlugins = mAllowPlugins;
1321
    *aAllowPlugins = mAllowPlugins;
1322
    if (!mAllowPlugins) {
1323
        return NS_OK;
1324
    }
1325
1326
    PRBool unsafe;
1327
    *aAllowPlugins = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe;
1300
    return NS_OK;
1328
    return NS_OK;
1301
}
1329
}
1302
1330
 Lines 1314-1319   nsDocShell::GetAllowJavascript(PRBool * Link Here 
1314
    NS_ENSURE_ARG_POINTER(aAllowJavascript);
1342
    NS_ENSURE_ARG_POINTER(aAllowJavascript);
1315
1343
1316
    *aAllowJavascript = mAllowJavascript;
1344
    *aAllowJavascript = mAllowJavascript;
1345
    if (!mAllowJavascript) {
1346
        return NS_OK;
1347
    }
1348
1349
    PRBool unsafe;
1350
    *aAllowJavascript = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe;
1317
    return NS_OK;
1351
    return NS_OK;
1318
}
1352
}
1319
1353
 Lines 1329-1334   NS_IMETHODIMP nsDocShell::GetAllowMetaRe Link Here 
1329
    NS_ENSURE_ARG_POINTER(aReturn);
1363
    NS_ENSURE_ARG_POINTER(aReturn);
1330
1364
1331
    *aReturn = mAllowMetaRedirects;
1365
    *aReturn = mAllowMetaRedirects;
1366
    if (!mAllowMetaRedirects) {
1367
        return NS_OK;
1368
    }
1369
1370
    PRBool unsafe;
1371
    *aReturn = NS_SUCCEEDED(ChannelIsUnsafe(&unsafe)) && !unsafe;
1332
    return NS_OK;
1372
    return NS_OK;
1333
}
1373
}
1334
1374
(-)a/docshell/base/nsDocShell.h (-1 / +4 lines)
Line     Link Here 
 Lines 513-519   protected: Link Here 
513
513
514
    // Check whether aURI is about:blank
514
    // Check whether aURI is about:blank
515
    static PRBool IsAboutBlank(nsIURI* aURI);
515
    static PRBool IsAboutBlank(nsIURI* aURI);
516
    
516
517
    // Check for a suspicious channel (such as a JAR channel where the
518
    // server-returned content type isn't a known JAR type)
519
    nsresult ChannelIsUnsafe(PRBool *aUnsafe);
517
protected:
520
protected:
518
    // Override the parent setter from nsDocLoader
521
    // Override the parent setter from nsDocLoader
519
    virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
522
    virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
(-)a/modules/libjar/nsIJARChannel.idl (-1 / +8 lines)
Line     Link Here 
 Lines 37-43    Link Here 
37
37
38
#include "nsIChannel.idl"
38
#include "nsIChannel.idl"
39
39
40
[scriptable, uuid(c7e410d1-85f2-11d3-9f63-006008a6efe9)]
40
[scriptable, uuid(6e6cc56d-51eb-4299-a795-dcfd1229ab3d)]
41
interface nsIJARChannel : nsIChannel 
41
interface nsIJARChannel : nsIChannel 
42
{
42
{
43
    /**
44
     * Returns TRUE if the JAR file is not safe (if the content type reported
45
     * by the server for a remote JAR is not of an expected type).  Scripting,
46
     * redirects, and plugins should be disabled when loading from this
47
     * channel.
48
     */
49
    readonly attribute boolean isUnsafe;
43
};
50
};
(-)a/modules/libjar/nsJARChannel.cpp (-1 / +61 lines)
Line     Link Here 
 Lines 44-49    Link Here 
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
    }
(-)a/modules/libjar/nsJARChannel.h (-1 / +2 lines)
Line     Link Here 
 Lines 97-103   private: Link Here 
97
    PRInt32                         mContentLength;
97
    PRInt32                         mContentLength;
98
    PRUint32                        mLoadFlags;
98
    PRUint32                        mLoadFlags;
99
    nsresult                        mStatus;
99
    nsresult                        mStatus;
100
    PRBool                          mIsPending;
100
    PRPackedBool                    mIsPending;
101
    PRPackedBool                    mIsUnsafe;
101
102
102
    nsJARInputThunk                *mJarInput;
103
    nsJARInputThunk                *mJarInput;
103
    nsCOMPtr<nsIStreamListener>     mDownloader;
104
    nsCOMPtr<nsIStreamListener>     mDownloader;
(-)a/modules/libpref/src/init/all.js (+5 lines)
Line     Link Here 
 Lines 612-617   pref("network.http.pipelining.maxrequest Link Here 
612
pref("network.http.pipelining.maxrequests" , 4);
612
pref("network.http.pipelining.maxrequests" , 4);
613
613
614
// </http>
614
// </http>
615
616
// If false, remote JAR files that are served with a content type other than
617
// application/java-archive or application/x-jar will not be opened
618
// by the jar channel.
619
pref("network.jar.open-unsafe-types", false);
615
620
616
// This preference controls whether or not internationalized domain names (IDN)
621
// This preference controls whether or not internationalized domain names (IDN)
617
// are handled.  IDN requires a nsIIDNService implementation.
622
// are handled.  IDN requires a nsIIDNService implementation.

Return to bug 369814