From 51ad4a10fab5f42b3f38983d354bdb10e020d858 Mon Sep 17 00:00:00 2001 From: Sophie Hamilton Date: Sat, 20 May 2017 00:12:16 +0100 Subject: [PATCH] Update xkcdViewer provider to use HTTPS URLs 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 #70. --- .../java/net/bytten/xkcdviewer/XkcdComicDefinition.java | 4 ++-- .../main/java/net/bytten/xkcdviewer/XkcdComicInfo.java | 2 +- .../java/net/bytten/xkcdviewer/XkcdComicProvider.java | 8 ++++---- xkcdViewer/src/main/res/values/strings.xml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicDefinition.java b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicDefinition.java index 885c2ae..82c2850 100644 --- a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicDefinition.java +++ b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicDefinition.java @@ -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 @@ -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 diff --git a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicInfo.java b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicInfo.java index 7652d41..d3af011 100644 --- a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicInfo.java +++ b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicInfo.java @@ -48,7 +48,7 @@ public String getTitle() { @Override public String getUrl() { - return "http://xkcd.com/"+getId()+"/"; + return "https://xkcd.com/"+getId()+"/"; } @Override diff --git a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicProvider.java b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicProvider.java index bceae06..7bbe83e 100644 --- a/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicProvider.java +++ b/xkcdViewer/src/main/java/net/bytten/xkcdviewer/XkcdComicProvider.java @@ -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*([^<]+)
\\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; @@ -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()); @@ -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 diff --git a/xkcdViewer/src/main/res/values/strings.xml b/xkcdViewer/src/main/res/values/strings.xml index 5d5cdb9..03974f8 100644 --- a/xkcdViewer/src/main/res/values/strings.xml +++ b/xkcdViewer/src/main/res/values/strings.xml @@ -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