From ade95f6343e027991b54f67dd9d99464a6b6de1a Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Tue, 14 Nov 2017 22:54:30 +0100 Subject: [PATCH] Fixes #340 by not crashing (and showing an error message) if a magnet link (url) is incorrectly structured. --- .../main/java/org/transdroid/core/gui/TorrentsActivity.java | 5 +++++ latest-search.html | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 latest-search.html diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java index 9da9c472..1ec83c81 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -1054,6 +1054,11 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE url = URLDecoder.decode(url, "UTF-8"); } catch (UnsupportedEncodingException e) { // Ignore: UTF-8 is always available on Android devices + } catch (IllegalArgumentException e) { + // Illegal character or escape sequence; fail task to show error + onCommunicationError(new DaemonTaskFailureResult(AddByMagnetUrlTask.create(currentConnection, url), + new DaemonException(DaemonException.ExceptionType.FileAccessError, "Invalid characters in magnet link")), false); + return; } AddByMagnetUrlTask addByMagnetUrlTask = AddByMagnetUrlTask.create(currentConnection, url); diff --git a/latest-search.html b/latest-search.html deleted file mode 100644 index 27562fe3..00000000 --- a/latest-search.html +++ /dev/null @@ -1 +0,0 @@ -30|3.7