-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly encode URL query parameters when building a cloning URL #5641
Properly encode URL query parameters when building a cloning URL #5641
Conversation
Test the query parameters of a Location when the Description contains a & character.
Utilize urllib.parse to handle encoding the param dictionary.
…repare_cloned_field_space_characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Can you add a changes/5640.fixed
changelog fragment to the diffs?
@@ -269,7 +270,7 @@ def prepare_cloned_fields(instance): | |||
for tag in instance.tags.all(): | |||
params.append(("tags", tag.pk)) | |||
|
|||
# Concatenate parameters into a URL query string | |||
param_string = "&".join([f"{k}={v}" for k, v in params]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof. I'm surprised this stuck around for as long as it has. Thanks for the fix!
If you'd like to go wild, there's some similarly sketchy-looking logic in nautobot.core.tables.LinkedCountColumn.render()
that probably could do with a similar fix, though based on its context it's likely a lot less impactful. Not required for this PR!
I'll add that changelog fragment here shortly and update the PR. |
…repare-cloned-fileds-special-characters
Closes #5640
What's Changed
Switch to utilize urllib.parse.urlencode to generate the query parameter string when cloning an object.
Screenshots
Before
Before this patch a location with the description "9th & Vine" (well anything with a special character in it) would not populate the dialog properly when cloning.
After
Now the clone dialog shows the description as expected.
TODO