Explorar o código

Fixes #7471: Correct redirect URL when attaching images via "add another" button

jeremystretch %!s(int64=4) %!d(string=hai) anos
pai
achega
b73db750e5
Modificáronse 2 ficheiros con 3 adicións e 5 borrados
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 2 5
      netbox/netbox/views/generic.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -4,6 +4,7 @@
 
 
 ### Bug Fixes
 ### Bug Fixes
 
 
+* [#7471](https://github.com/netbox-community/netbox/issues/7471) - Correct redirect URL when attaching images via "add another" button
 * [#7474](https://github.com/netbox-community/netbox/issues/7474) - Fix AttributeError exception when rendering a report or custom script
 * [#7474](https://github.com/netbox-community/netbox/issues/7474) - Fix AttributeError exception when rendering a report or custom script
 
 
 ---
 ---

+ 2 - 5
netbox/netbox/views/generic.py

@@ -282,14 +282,11 @@ class ObjectEditView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
                 messages.success(request, mark_safe(msg))
                 messages.success(request, mark_safe(msg))
 
 
                 if '_addanother' in request.POST:
                 if '_addanother' in request.POST:
-                    redirect_url = request.path
-                    return_url = request.GET.get('return_url')
-                    if return_url is not None and is_safe_url(url=return_url, allowed_hosts=request.get_host()):
-                        redirect_url = f'{redirect_url}?return_url={return_url}'
+                    redirect_url = request.get_full_path()
 
 
                     # If the object has clone_fields, pre-populate a new instance of the form
                     # If the object has clone_fields, pre-populate a new instance of the form
                     if hasattr(obj, 'clone_fields'):
                     if hasattr(obj, 'clone_fields'):
-                        redirect_url += f"{'&' if return_url else '?'}{prepare_cloned_fields(obj)}"
+                        redirect_url += f"{'&' if '?' in redirect_url else '?'}{prepare_cloned_fields(obj)}"
 
 
                     return redirect(redirect_url)
                     return redirect(redirect_url)