diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-03-12 18:09:12 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-03-12 18:09:12 -0700 |
commit | d3fe79923456e53a7c68360364c730b270759def (patch) | |
tree | 70ca757e10eb08ade926b4dff10f200dce49de34 /src/github/daneren2005 | |
parent | 609c0aa6d1ce5f8bc1971954795975c7670b80eb (diff) | |
download | dsub-d3fe79923456e53a7c68360364c730b270759def.tar.gz dsub-d3fe79923456e53a7c68360364c730b270759def.tar.bz2 dsub-d3fe79923456e53a7c68360364c730b270759def.zip |
Fix a bunch of issues related incorrect .subsonic.org url's redirecting to subsonic front page
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r-- | src/github/daneren2005/dsub/service/RESTMusicService.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 2f714d91..6caf2ade 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -91,6 +91,7 @@ import github.daneren2005.dsub.service.parser.SearchResult2Parser; import github.daneren2005.dsub.service.parser.SearchResultParser; import github.daneren2005.dsub.service.parser.ShareParser; import github.daneren2005.dsub.service.parser.StarredListParser; +import github.daneren2005.dsub.service.parser.SubsonicRESTException; import github.daneren2005.dsub.service.parser.UserParser; import github.daneren2005.dsub.service.parser.VideosParser; import github.daneren2005.dsub.service.ssl.SSLSocketFactory; @@ -1829,7 +1830,7 @@ public class RESTMusicService implements MusicService { } } - private void detectRedirect(String originalUrl, Context context, HttpContext httpContext) { + private void detectRedirect(String originalUrl, Context context, HttpContext httpContext) throws Exception { HttpUriRequest request = (HttpUriRequest) httpContext.getAttribute(ExecutionContext.HTTP_REQUEST); HttpHost host = (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST); @@ -1841,10 +1842,15 @@ public class RESTMusicService implements MusicService { redirectedUrl = request.getURI().toString(); } - int index = originalUrl.indexOf("/rest/"); - if(index != -1) { - redirectFrom = originalUrl.substring(0, index); - redirectTo = redirectedUrl.substring(0, redirectedUrl.indexOf("/rest/")); + if(redirectedUrl != null && "http://subsonic.org/pages/".equals(redirectedUrl)) { + throw new Exception("Invalid url, redirects to http://subsonic.org/pages/"); + } + + int fromIndex = originalUrl.indexOf("/rest/"); + int toIndex = redirectedUrl.indexOf("/rest/"); + if(fromIndex != -1 && toIndex != -1 && !Util.equals(originalUrl, redirectedUrl)) { + redirectFrom = originalUrl.substring(0, fromIndex); + redirectTo = redirectedUrl.substring(0, toIndex); if (redirectFrom.compareTo(redirectTo) != 0) { Log.i(TAG, redirectFrom + " redirects to " + redirectTo); |