WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

Last modified 8 weeks ago

#47723 closed defect (bug) (fixed)

Adding a custom link in nav-menus.php doesn't trim whitespace

Reported by: majemedia Owned by: audrasjb
Milestone: 5.2.3 Priority: normal
Severity: minor Version:
Component: Menus Keywords: good-first-bug fixed-major
Focuses: ui Cc:
PR Number:

Description

When building a nav-menu and utilizing custom links the entered value isn't trimmed.

Once you click 'Add to Menu':

  • If you have whitespace at the start: no url added to the custom link in the menu item
  • If you have whitespace at the end: %20 is added to the custom link

Attachments (1)

47723.diff (548 bytes) - added by majemedia 3 months ago.
patch for #47723

Download all attachments as: .zip

Change History (16)

#1 @audrasjb
3 months ago

  • Focuses administration removed
  • Keywords needs-patch good-first-bug added; dev-feedback removed
  • Owner set to audrasjb
  • Status changed from new to accepted
  • Version 5.2.2 deleted

Hi and thanks for your report.

Milestoning this one to next major.

#2 @audrasjb
3 months ago

  • Milestone changed from Awaiting Review to 5.3

@majemedia
3 months ago

patch for #47723

#3 @SergeyBiryukov
3 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 45655:

Menus: Trim whitespace from custom link URLs.

Props majemedia, SergeyBiryukov.
Fixes #47723.

#4 @SergeyBiryukov
3 months ago

In 45656:

Coding Standards: Fix WPCS issues in [45655].

See #47723.

#5 @audrasjb
3 months ago

  • Keywords needs-patch removed

This ticket was mentioned in Slack in #core by majemedia. View the logs.


2 months ago

#7 @audrasjb
2 months ago

  • Keywords needs-testing fixed-major added
  • Milestone changed from 5.3 to 5.2.3
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this so it can be back-ported to the 5.2 branch.
Also adding needs-testing keyword to validate if this ticket is good to land in 5.2.3 (should be ok though).

#8 @majemedia
2 months ago

I've tested the fix against a 5.2 branch checkout and its working as expected to me with no regressions.

Tested:

  • Leading space
  • Ending space
  • Leading and ending space
  • No leading/ending space

Note that I did not apply the test file generated by the original trunk commit.

#9 @audrasjb
2 months ago

  • Keywords needs-testing removed

Also tested on my side against 5.2.2, and everything looks ok.

The patch applies cleanly and works fine in my tests.
Note: there is two changesets to apply: [45655] and [45656] (coding standards fixes after [45655]).

Good to go 👌

#10 @donmhico
2 months ago

+1 Patch applies cleanly and problem resolves. However it's good to point out that the issue with ending whitespace still happens when you add the custom link via Customizer. But I think that can be another ticket.

#11 @donmhico
2 months ago

See #47888 regarding the same bug in Customize.

#12 @SergeyBiryukov
2 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 45832:

Menus: Trim whitespace from custom link URLs.

Props majemedia, SergeyBiryukov.
Merges [45655] and [45656] to the 5.2 branch.
Fixes #47723.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


8 weeks ago

#14 @SergeyBiryukov
8 weeks ago

In 45869:

Customizer: Trim whitespace from custom link URLs.

This complements a similar fix for the Menus screen in [45655].

Props donmhico, audrasjb.
Fixes #47888. See #47723.

#15 @SergeyBiryukov
8 weeks ago

In 45870:

Customizer: Trim whitespace from custom link URLs.

This complements a similar fix for the Menus screen in [45655].

Props donmhico, audrasjb.
Merges [45869] to the 5.2 branch.
Fixes #47888. See #47723.

Note: See TracTickets for help on using tickets.