Module: kamailio
Branch: master
Commit: 91abfdf6ebf942cbb0234be36812a9513f92f96b
URL: 
https://github.com/kamailio/kamailio/commit/91abfdf6ebf942cbb0234be36812a9513f92f96b

Author: Kent <k...@amtelco.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-11-19T16:00:45+01:00

lib/srdb1: Allow '/' in database URL passwords

- Modify parsing of a database URL so that a '/' character is accepted
  as a valid character in the password part of the URL.

---

Modified: src/lib/srdb1/db_id.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/91abfdf6ebf942cbb0234be36812a9513f92f96b.diff
Patch: 
https://github.com/kamailio/kamailio/commit/91abfdf6ebf942cbb0234be36812a9513f92f96b.patch

---

diff --git a/src/lib/srdb1/db_id.c b/src/lib/srdb1/db_id.c
index 93b36253b3b..2546a5f56f0 100644
--- a/src/lib/srdb1/db_id.c
+++ b/src/lib/srdb1/db_id.c
@@ -237,14 +237,33 @@ static int parse_db_url(struct db_id *id, const str *url)
                                                break;
 
                                        case '/':
-                                               id->host = prev_token;
-                                               prev_token = 0;
-                                               id->port = str2s(begin, url->s 
+ i - begin, 0);
-                                               if(dupl_string_name(
-                                                                  
&id->database, url->s + i + 1, url->s + len)
-                                                               < 0)
-                                                       goto err;
-                                               return 0;
+                                               /* go to last '@' when '/' is 
part of a password */
+                                               a = 0;
+                                               for(j = i + 1; j < len; j++) {
+                                                       if(url->s[j] == '@') {
+                                                               a = j;
+                                                       }
+                                               }
+                                               if(a != 0) {
+                                                       st = ST_HOST;
+                                                       id->username = 
prev_token;
+                                                       prev_token = 0;
+                                                       i = a;
+                                                       
if(dupl_string(&id->password, begin, url->s + i)
+                                                                       < 0)
+                                                               goto err;
+                                                       begin = url->s + i + 1;
+                                                       break;
+                                               } else {
+                                                       id->host = prev_token;
+                                                       prev_token = 0;
+                                                       id->port = str2s(begin, 
url->s + i - begin, 0);
+                                                       
if(dupl_string_name(&id->database, url->s + i + 1,
+                                                                          
url->s + len)
+                                                                       < 0)
+                                                               goto err;
+                                                       return 0;
+                                               }
                                }
                                break;
 

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to