1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

Fixed logic of HTTPS downgrade detection for multiple redirections, and grant that redirection if followed for HTTP servers

This commit is contained in:
David A. Velasco 2014-08-06 11:16:17 +02:00
parent 07f3d9caae
commit e43e43f51a

View File

@ -85,25 +85,26 @@ public class GetRemoteStatusOperation extends RemoteOperation {
get.getResponseHeaders() get.getResponseHeaders()
); );
if (baseUrlSt.startsWith("https://")) { String redirectedLocation = mLatestResult.getRedirectedLocation();
String redirectedLocation = mLatestResult.getRedirectedLocation(); while (redirectedLocation != null && redirectedLocation.length() > 0
while (redirectedLocation != null && redirectedLocation.length() > 0 && !mLatestResult.isSuccess()) {
&& !mLatestResult.isSuccess()) {
isRedirectToNonSecureConnection = redirectedLocation.startsWith("http://"); isRedirectToNonSecureConnection |= (
get.releaseConnection(); baseUrlSt.startsWith("https://") &&
get = new GetMethod(redirectedLocation); redirectedLocation.startsWith("http://")
status = client.executeMethod( );
get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT get.releaseConnection();
); get = new GetMethod(redirectedLocation);
mLatestResult = new RemoteOperationResult( status = client.executeMethod(
(status == HttpStatus.SC_OK), get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT
status, );
get.getResponseHeaders() mLatestResult = new RemoteOperationResult(
); (status == HttpStatus.SC_OK),
redirectedLocation = mLatestResult.getRedirectedLocation(); status,
} get.getResponseHeaders()
} );
redirectedLocation = mLatestResult.getRedirectedLocation();
}
String response = get.getResponseBodyAsString(); String response = get.getResponseBodyAsString();
if (status == HttpStatus.SC_OK) { if (status == HttpStatus.SC_OK) {