diff --git a/source/net/filebot/WebServices.java b/source/net/filebot/WebServices.java index 1e91ac25..c6dfc6cd 100644 --- a/source/net/filebot/WebServices.java +++ b/source/net/filebot/WebServices.java @@ -234,17 +234,25 @@ public final class WebServices { } public static String[] getLogin(String key) { - return Settings.forPackage(WebServices.class).get(key, ":").split(":", 2); + try { + String[] values = Settings.forPackage(WebServices.class).get(key, ":").split(":", 2); // empty username/password by default + if (values != null && values.length == 2 && values[0] != null && values[1] != null) { + return values; + } + } catch (Exception e) { + Logger.getLogger(WebServices.class.getName()).log(Level.WARNING, e.getMessage(), e); + } + return new String[] { "", "" }; } public static void setLogin(String id, String user, String password) { - Settings settings = Settings.forPackage(WebServices.class); - String value = user.length() > 0 && password.length() > 0 ? user + ":" + password : null; - if (value == null) { - user = ""; - password = ""; + if (user == null || password == null || user.contains(":") || (user.isEmpty() && !password.isEmpty()) || (!user.isEmpty() && password.isEmpty())) { + throw new IllegalArgumentException("Illegal login: " + user); } + Settings settings = Settings.forPackage(WebServices.class); + String value = user.isEmpty() && password.isEmpty() ? null : user + ":" + password; + if (id.equals("osdb.user")) { settings.put(id, value); OpenSubtitles.setUser(user, password); diff --git a/source/net/filebot/ui/subtitle/SubtitlePanel.java b/source/net/filebot/ui/subtitle/SubtitlePanel.java index 9af98e80..9604b7d6 100644 --- a/source/net/filebot/ui/subtitle/SubtitlePanel.java +++ b/source/net/filebot/ui/subtitle/SubtitlePanel.java @@ -40,6 +40,7 @@ import net.filebot.ui.AbstractSearchPanel; import net.filebot.ui.LanguageComboBox; import net.filebot.ui.SelectDialog; import net.filebot.util.ui.LabelProvider; +import net.filebot.util.ui.LinkButton; import net.filebot.util.ui.SimpleLabelProvider; import net.filebot.web.OpenSubtitlesClient; import net.filebot.web.SearchResult; @@ -261,7 +262,18 @@ public class SubtitlePanel extends AbstractSearchPanel