Skip to content

Commit b73db75

Browse files
committed
Fixes #7471: Correct redirect URL when attaching images via "add another" button
1 parent 3f766ff commit b73db75

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Bug Fixes
66

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

910
---

netbox/netbox/views/generic.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,11 @@ def post(self, request, *args, **kwargs):
282282
messages.success(request, mark_safe(msg))
283283

284284
if '_addanother' in request.POST:
285-
redirect_url = request.path
286-
return_url = request.GET.get('return_url')
287-
if return_url is not None and is_safe_url(url=return_url, allowed_hosts=request.get_host()):
288-
redirect_url = f'{redirect_url}?return_url={return_url}'
285+
redirect_url = request.get_full_path()
289286

290287
# If the object has clone_fields, pre-populate a new instance of the form
291288
if hasattr(obj, 'clone_fields'):
292-
redirect_url += f"{'&' if return_url else '?'}{prepare_cloned_fields(obj)}"
289+
redirect_url += f"{'&' if '?' in redirect_url else '?'}{prepare_cloned_fields(obj)}"
293290

294291
return redirect(redirect_url)
295292

0 commit comments

Comments
 (0)