Commit 8db44df1 authored by Georg Koppen's avatar Georg Koppen
Browse files

Bug 24052: Streamline handling of file:// resources

We should make sure restrictions regarding loading of file:// resources
are adhered to more strictly, at least on *nix platforms.

This is a workaround for
https://bugzilla.mozilla.org/show_bug.cgi?id=1412081.
parent 019d53c2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -789,12 +789,20 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
        // if calling newChannel2() fails we try to fall back to
        // creating a new channel by calling NewChannel().
        if (NS_FAILED(rv)) {
#ifdef XP_UNIX
        if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
            return rv;
        } else {
#endif
            rv = handler->NewChannel(aURI, getter_AddRefs(channel));
            NS_ENSURE_SUCCESS(rv, rv);
            // The protocol handler does not implement NewChannel2, so
            // maybe we need to wrap the channel (see comment in MaybeWrap
            // function).
            channel = nsSecCheckWrapChannel::MaybeWrap(channel, aLoadInfo);
#ifdef XP_UNIX
        }
#endif
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -188,6 +188,13 @@ nsFileProtocolHandler::NewChannel2(nsIURI* uri,
                                   nsILoadInfo* aLoadInfo,
                                   nsIChannel** result)
{
#ifdef XP_UNIX
    if (aLoadInfo && aLoadInfo->TriggeringPrincipal()) {
      if (aLoadInfo->TriggeringPrincipal()->GetIsCodebasePrincipal()) {
        return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
      }
    }
#endif
    nsFileChannel *chan = new nsFileChannel(uri);
    if (!chan)
        return NS_ERROR_OUT_OF_MEMORY;