From a8293a52872f46e79aaffe904d2a3a1d951143cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20Maillart?= <tmaillart@freebox.fr>
Date: Tue, 29 Nov 2022 09:06:46 +0100
Subject: [PATCH] add support for optional password in url

---
 lib/init.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/init.c b/lib/init.c
index ed9d49b..6256562 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -225,7 +225,14 @@ struct smb2_url *smb2_parse_url(struct smb2_context *smb2, const char *url)
         }
         /* user */
         if ((tmp = strchr(ptr, '@')) != NULL && strlen(tmp) > len_shared_folder) {
+                char *t = strchr(ptr, ':');
+
                 *(tmp++) = '\0';
+                /* optional password */
+                if (t && t < tmp) {
+                        *t = '\0';
+                        smb2_set_password(smb2, t + 1);
+                }
                 u->user = strdup(ptr);
                 ptr = tmp;
         }
-- 
2.37.3

