From 429d0452741a387de15c9a7bd1f56ceb3aacfc51 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 20 May 2016 11:43:29 +0200 Subject: [PATCH] Prevent crash when connecting to an Rtorrent client with a space in host name or SCGI mount folder. Fixes #296. --- .../org/transdroid/daemon/Rtorrent/RtorrentAdapter.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java index 8f11f03e..96f231e4 100644 --- a/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java @@ -17,6 +17,8 @@ */ package org.transdroid.daemon.Rtorrent; +import android.text.TextUtils; + import org.transdroid.core.gui.log.Log; import org.transdroid.daemon.Daemon; import org.transdroid.daemon.DaemonException; @@ -367,9 +369,10 @@ public class RtorrentAdapter implements IDaemonAdapter { * @return The URL of the RPC API */ private String buildWebUIUrl() { - return (settings.getSsl() ? "https://" : "http://") + settings.getAddress() + ":" + settings.getPort() + - (settings.getFolder() == null || settings.getFolder().equals("") ? DEFAULT_RPC_URL : - settings.getFolder()); + String address = settings.getAddress() == null ? "" : settings.getAddress().trim(); + String folder = settings.getFolder() == null ? "" : settings.getFolder().trim(); + return (settings.getSsl() ? "https://" : "http://") + address + ":" + settings.getPort() + + (TextUtils.isEmpty(folder) ? DEFAULT_RPC_URL : folder); } private List onTorrentsRetrieved(Object response) throws DaemonException {