Skip to content

Commit

Permalink
Update xkcdViewer provider to use HTTPS URLs
Browse files Browse the repository at this point in the history
xkcd.com changed to using HTTPS some time ago; the change causes
XkcdViewer to fail with "Data returned from website didn't match
expected format" as the 301 redirect is attempted to be parsed as JSON,
which obviously fails.

While this isn't a complete fix, it should hopefully fix the app enough
for it to work again.

Fixes tcoxon#70.
  • Loading branch information
Sophira committed May 19, 2017
1 parent 058c064 commit 51ad4a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public XkcdComicDefinition() {

@Override
public Uri getArchiveUrl() {
return Uri.parse("http://xkcd.com/archive/");
return Uri.parse("https://xkcd.com/archive/");
}

@Override
Expand All @@ -35,7 +35,7 @@ public String getAuthorLinkText() {

@Override
public Uri getAuthorLinkUrl() {
return Uri.parse("http://store.xkcd.com/");
return Uri.parse("https://store.xkcd.com/");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getTitle() {

@Override
public String getUrl() {
return "http://xkcd.com/"+getId()+"/";
return "https://xkcd.com/"+getId()+"/";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class XkcdComicProvider implements IComicProvider {
private static final Pattern archiveItemPattern = Pattern.compile(
// group(1): comic number; group(2): date; group(3): title
"\\s*<a href=\"/(\\d+)/\" title=\"(\\d+-\\d+-\\d+)\">([^<]+)</a><br/>\\s*");
private static final String ARCHIVE_URL = "http://www.xkcd.com/archive/";
private static final String ARCHIVE_URL = "https://www.xkcd.com/archive/";

private XkcdComicDefinition def;

Expand All @@ -43,13 +43,13 @@ public Uri comicDataUrlForUrl(Uri url) {

@Override
public Uri createComicUrl(String comicId) {
return Uri.parse("http://xkcd.com/"+comicId+"/info.0.json");
return Uri.parse("https://xkcd.com/"+comicId+"/info.0.json");
}

@Override
public IComicInfo fetchComicInfo(Uri url) throws Exception {
// Uses xkcd's JSON interface
// (http://xkcd.com/json.html)
// (https://xkcd.com/json.html)
String text = Utility.blockingReadUri(url);
JSONObject obj = (JSONObject)new JSONTokener(text).nextValue();
Log.d("json", obj.names().toString());
Expand Down Expand Up @@ -91,7 +91,7 @@ public Uri fetchRandomComicUrl() throws Exception {

@Override
public Uri getFinalComicUrl() {
return Uri.parse("http://xkcd.com/info.0.json");
return Uri.parse("https://xkcd.com/info.0.json");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion xkcdViewer/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xkcdViewer v%s. Application for viewing xkcd comics with hover text.\n\n
xkcdViewer Copyright (C) 2009-2017, Tom Coxon, Tyler Breisacher, David
McCullough, Kristian Lundkvist.\n\n
xkcd is Copyright (C) 2006 - 2017, Randall Munroe (http://xkcd.com)\n\n
xkcd is Copyright (C) 2006 - 2017, Randall Munroe (https://xkcd.com)\n\n
Contains some menu icons from www.androidicons.com, licensed under a
Creative Commons Attribution - Share Alike license.\n\n
Application icon kindly donated by Johan Larsson.\n\n
Expand Down

0 comments on commit 51ad4a1

Please sign in to comment.