Explorar o código

Fixes #12046: Fix URL parsing for git data sources

jeremystretch %!s(int64=3) %!d(string=hai) anos
pai
achega
06dec6a2d9
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  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')
         password = self.params.get('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:
             url = self.url