From bb98d031c795991db96045c404ae8191ae5026da Mon Sep 17 00:00:00 2001 From: Shritesh Date: Sat, 7 Oct 2023 00:20:44 +0530 Subject: [PATCH] Fixed domain, username & password extraction logic for URLs. --- .../ui/dialogs/SmbConnectDialog.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/dialogs/SmbConnectDialog.java b/app/src/main/java/com/amaze/filemanager/ui/dialogs/SmbConnectDialog.java index cece107587..ab73e4c7b4 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/dialogs/SmbConnectDialog.java +++ b/app/src/main/java/com/amaze/filemanager/ui/dialogs/SmbConnectDialog.java @@ -265,15 +265,18 @@ public void afterTextChanged(@NonNull Editable s) { int domainDelim = !inf.contains(";") ? 0 : inf.indexOf(';'); domainp = inf.substring(0, domainDelim); if (domainp != null && domainp.length() > 0) inf = inf.substring(domainDelim + 1); - userp = inf.substring(0, inf.indexOf(":")); - try { - passp = - PasswordUtil.INSTANCE.decryptPassword( - context, inf.substring(inf.indexOf(COLON) + 1), URL_SAFE); - passp = decode(passp, Charsets.UTF_8.name()); - } catch (GeneralSecurityException | IOException e) { - LOG.warn("Error decrypting password", e); - passp = ""; + if (!inf.contains(":")) userp = inf; + else { + userp = inf.substring(0, inf.indexOf(COLON)); + try { + passp = + PasswordUtil.INSTANCE.decryptPassword( + context, inf.substring(inf.indexOf(COLON) + 1), URL_SAFE); + passp = decode(passp, Charsets.UTF_8.name()); + } catch (GeneralSecurityException | IOException e) { + LOG.warn("Error decrypting password", e); + passp = ""; + } } domain.setText(domainp); user.setText(userp);