Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-06-12 15:16:10 +08:00
commit 6d9126c486
2 changed files with 15 additions and 13 deletions

View file

@ -27,24 +27,22 @@ public:
: mSink(sink) : mSink(sink)
, mTarget(target) , mTarget(target)
, mLock("nsTransportEventSinkProxy.mLock") , mLock("nsTransportEventSinkProxy.mLock")
, mLastEvent(nullptr)
{ {
NS_ADDREF(mSink);
} }
private: private:
virtual ~nsTransportEventSinkProxy() virtual ~nsTransportEventSinkProxy()
{ {
// our reference to mSink could be the last, so be sure to release // our reference to mSink could be the last, so be sure to release
// it on the target thread. otherwise, we could get into trouble. // it on the target thread, otherwise, we could get into trouble.
NS_ProxyRelease(mTarget, dont_AddRef(mSink)); NS_ProxyRelease(mTarget, mSink.forget());
} }
public: public:
nsITransportEventSink *mSink; nsCOMPtr<nsITransportEventSink> mSink;
nsCOMPtr<nsIEventTarget> mTarget; nsCOMPtr<nsIEventTarget> mTarget;
Mutex mLock; Mutex mLock;
nsTransportStatusEvent *mLastEvent; RefPtr<nsTransportStatusEvent> mLastEvent;
}; };
class nsTransportStatusEvent : public Runnable class nsTransportStatusEvent : public Runnable
@ -70,12 +68,14 @@ public:
// if not coalescing all, then last event may not equal self! // if not coalescing all, then last event may not equal self!
{ {
MutexAutoLock lock(mProxy->mLock); MutexAutoLock lock(mProxy->mLock);
if (mProxy->mLastEvent == this) if (mProxy->mLastEvent == this) {
mProxy->mLastEvent = nullptr; mProxy->mLastEvent = nullptr;
}
} }
mProxy->mSink->OnTransportStatus(mTransport, mStatus, mProgress, mProxy->mSink->OnTransportStatus(mTransport, mStatus, mProgress,
mProgressMax); mProgressMax);
mProxy = nullptr;
return NS_OK; return NS_OK;
} }

View file

@ -3346,7 +3346,7 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI,
return newCookie; return newCookie;
} }
if (!CheckHiddenPrefix(cookieAttributes)) { if (!CheckHiddenPrefix(cookieAttributes)) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, "failed the CheckHiddenPrefix tests"); COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, "failed the hidden prefix tests");
return newCookie; return newCookie;
} }
// magic prefix checks. MUST be run after CheckDomain() and CheckPath() // magic prefix checks. MUST be run after CheckDomain() and CheckPath()
@ -4159,8 +4159,9 @@ nsCookieService::CheckHiddenPrefix(nsCookieAttributes &aCookie) {
static const int kSecureLen = sizeof( kSecure ) - 1; static const int kSecureLen = sizeof( kSecure ) - 1;
static const int kHostLen = sizeof( kHost ) - 1; static const int kHostLen = sizeof( kHost ) - 1;
bool isSecure = strncmp( aCookie.value.get(), kSecure, kSecureLen ) == 0; // As of RFC 6265 bis-11 draft, this should be a case *in*sensitive match.
bool isHost = strncmp( aCookie.value.get(), kHost, kHostLen ) == 0; bool isSecure = nsCRT::strncasecmp(aCookie.value.get(), kSecure, kSecureLen) == 0;
bool isHost = nsCRT::strncasecmp(aCookie.value.get(), kHost, kHostLen) == 0;
if (isSecure || isHost) { if (isSecure || isHost) {
return false; return false;
@ -4186,8 +4187,9 @@ nsCookieService::CheckPrefixes(nsCookieAttributes &aCookie,
static const int kSecureLen = sizeof( kSecure ) - 1; static const int kSecureLen = sizeof( kSecure ) - 1;
static const int kHostLen = sizeof( kHost ) - 1; static const int kHostLen = sizeof( kHost ) - 1;
bool isSecure = strncmp( aCookie.value.get(), kSecure, kSecureLen ) == 0; // As of RFC 6265 bis-11 draft, this should be a case *in*sensitive match.
bool isHost = strncmp( aCookie.value.get(), kHost, kHostLen ) == 0; bool isSecure = nsCRT::strncasecmp(aCookie.value.get(), kSecure, kSecureLen) == 0;
bool isHost = nsCRT::strncasecmp(aCookie.value.get(), kHost, kHostLen) == 0;
if ( !isSecure && !isHost ) { if ( !isSecure && !isHost ) {
// not one of the magic prefixes: carry on // not one of the magic prefixes: carry on