Bulk rename improperly strips "find" and "replace" fields #8629

Closed
opened 2025-12-29 20:39:06 +01:00 by adam · 1 comment
Owner

Originally created by @pv2b on GitHub (Sep 17, 2023).

Originally assigned to: @pv2b on GitHub.

NetBox version

v3.6.1

Python version

3.11

Steps to Reproduce

  1. On an existing device, create an interface labeled something like "One Two".
  2. Go to the interface tab of that device, check the checkbox next to it and hit "rename".
  3. In the find field, enter "One " (note the trailing space!). In the replacement field enter "One-".
  4. Click the preview button.

Expected Behavior

NetBox should offer to rename the device to "One-Two".

Observed Behavior

Netbox offers to rename the device to "One- Two" (note the space).

My guess (I've not looked at the code) is that this happens because django autostrips whitespace from input fields by default, and this needs to be disabled.

Also, the same bug exists on the "replace" field, and is completely analagous to the replace field.

Workaround: For the "find" field, use regex mode and \s to match trailing whitespace. For the "replace" field, I don't know of a general workaround.

Originally created by @pv2b on GitHub (Sep 17, 2023). Originally assigned to: @pv2b on GitHub. ### NetBox version v3.6.1 ### Python version 3.11 ### Steps to Reproduce 1. On an existing device, create an interface labeled something like "One Two". 2. Go to the interface tab of that device, check the checkbox next to it and hit "rename". 3. In the find field, enter "One " (note the trailing space!). In the replacement field enter "One-". 4. Click the preview button. ### Expected Behavior NetBox should offer to rename the device to "One-Two". ### Observed Behavior Netbox offers to rename the device to "One- Two" (note the space). My guess (I've not looked at the code) is that this happens because django autostrips whitespace from input fields by default, and this needs to be disabled. Also, the same bug exists on the "replace" field, and is completely analagous to the replace field. Workaround: For the "find" field, use regex mode and \s to match trailing whitespace. For the "replace" field, I don't know of a general workaround.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:39:06 +01:00
adam closed this issue 2025-12-29 20:39:06 +01:00
Author
Owner

@pv2b commented on GitHub (Sep 17, 2023):

I'm happy to volunteer to look at the code to fix this issue with a PR.

@pv2b commented on GitHub (Sep 17, 2023): I'm happy to volunteer to look at the code to fix this issue with a PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8629