Bläddra i källkod

Fixes #12046: Fix URL parsing for git data sources

jeremystretch 2 år sedan
förälder
incheckning
06dec6a2d9
1 ändrade filer med 3 tillägg och 4 borttagningar
  1. 3 4
      netbox/core/data_backends.py

+ 3 - 4
netbox/core/data_backends.py

@@ -91,10 +91,9 @@ class GitBackend(DataBackend):
         username = self.params.get('username')
         username = self.params.get('username')
         password = self.params.get('password')
         password = self.params.get('password')
         if username and password:
         if username and password:
-            url_components = list(urlparse(self.url))
-            # Prepend username & password to netloc
-            url_components[1] = quote(f'{username}@{password}:') + url_components[1]
-            url = urlunparse(url_components)
+            # Add username & password to URL
+            parsed = urlparse(self.url)
+            url = f'{parsed.scheme}://{quote(username)}:{quote(password)}@{parsed.netloc}{parsed.path}'
         else:
         else:
             url = self.url
             url = self.url