summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2022-02-25 19:34:07 +0100
committerByteHamster <info@bytehamster.com>2022-02-25 19:35:12 +0100
commit11d44f71405146ef2854b933526a6a741fc36b56 (patch)
treec13d6cda94071396e5b553046500b0debea4a9d7
parentecaba7525ff63b7837a370c2ccc3b5f8b1c52aed (diff)
downloadAntennaPod-11d44f71405146ef2854b933526a6a741fc36b56.zip
Fix credentials with colon
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java b/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java
index 667d6afeb..fff2eb25b 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/BasicAuthorizationInterceptor.java
@@ -59,14 +59,15 @@ public class BasicAuthorizationInterceptor implements Interceptor {
return response;
}
- String[] parts = userInfo.split(":");
- if (parts.length != 2) {
+ if (!userInfo.contains(":")) {
Log.d(TAG, "Invalid credentials for '" + request.url() + "'");
return response;
}
+ String username = userInfo.substring(0, userInfo.indexOf(':'));
+ String password = userInfo.substring(userInfo.indexOf(':') + 1);
Log.d(TAG, "Authorization failed, re-trying with ISO-8859-1 encoded credentials");
- String credentials = HttpDownloader.encodeCredentials(parts[0], parts[1], "ISO-8859-1");
+ String credentials = HttpDownloader.encodeCredentials(username, password, "ISO-8859-1");
newRequest.header(HEADER_AUTHORIZATION, credentials);
response = chain.proceed(newRequest.build());
@@ -75,7 +76,7 @@ public class BasicAuthorizationInterceptor implements Interceptor {
}
Log.d(TAG, "Authorization failed, re-trying with UTF-8 encoded credentials");
- credentials = HttpDownloader.encodeCredentials(parts[0], parts[1], "UTF-8");
+ credentials = HttpDownloader.encodeCredentials(username, password, "UTF-8");
newRequest.header(HEADER_AUTHORIZATION, credentials);
return chain.proceed(newRequest.build());
}