Don't allow cross-origin POST redirects on 308 codes.

We already don't allow cross origin POST redirects on 307 redirects;
this adds extra guards to make sure we don't allow them on 308s either.
This commit is contained in:
Kyle Machulis 2019-07-20 15:27:48 +02:00 • committed by Roy Tam
commit b2512d610b

View file

@ -1381,7 +1381,7 @@ nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsICh
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Don't allow cross-origin 307 POST redirects. // Don't allow cross-origin 307/308 POST redirects.
nsCOMPtr<nsIHttpChannel> oldHttpChannel(do_QueryInterface(oldChannel)); nsCOMPtr<nsIHttpChannel> oldHttpChannel(do_QueryInterface(oldChannel));
if (oldHttpChannel) { if (oldHttpChannel) {
uint32_t responseStatus; uint32_t responseStatus;
@ -1389,7 +1389,7 @@ nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsICh
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
if (responseStatus == 307) { if (responseStatus == 307 || responseStatus == 308) {
nsAutoCString method; nsAutoCString method;
rv = oldHttpChannel->GetRequestMethod(method); rv = oldHttpChannel->GetRequestMethod(method);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {