WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#47888 closed defect (bug) (fixed)

Adding a custom link in menu via Customize doesn't trim whitespace.

Reported by: donmhico Owned by: audrasjb
Milestone: 5.2.3 Priority: normal
Severity: normal Version:
Component: Menus Keywords: has-patch commit
Focuses: Cc:
PR Number:

Description

Steps to reproduce bug.

  1. Click "Customize" on any front-end page.
  2. Try to add / edit a Menu and add a Custom Link.

The following behaviour happens.

  1. If the URL has a whitespace in front. e.g. https://wp.org/
    • URL field box will have red border and the custom link won't be added.
  1. If the URL has a whitespace in the end. e.g. https://wp.org/
    • Custom link will be added but if the menu will have the link https://wp.org/%20

I think it would be best if the URL is trimmed before the checking of URL regex happens.

Attachments (2)

47888.diff (1.4 KB) - added by donmhico 3 months ago.
db82be8a10468c2f56bf04cad39c1f8c.gif (388.1 KB) - added by audrasjb 3 months ago.

Download all attachments as: .zip

Change History (13)

@donmhico
3 months ago

#2 @donmhico
3 months ago

  • Keywords has-patch added

#3 @audrasjb
3 months ago

  • Component changed from General to Menus
  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Awaiting Review to 5.2.3
  • Owner set to audrasjb
  • Status changed from new to assigned

Moving to 5.2.3: we should handle this ticket alongside #47723

#4 @SergeyBiryukov
3 months ago

  • Keywords has-patch added; needs-patch removed
  • Owner changed from audrasjb to SergeyBiryukov
  • Status changed from assigned to reviewing

#5 @SergeyBiryukov
3 months ago

  • Owner changed from SergeyBiryukov to audrasjb

#6 @audrasjb
3 months ago

  • Status changed from reviewing to accepted

Thanks @donmhico
47888.diff works like a charm on my side (see screenshot above).
Good to go :)

#7 @donmhico
3 months ago

@audrasjb You're welcome. Awesome gif BTW :)

#8 @audrasjb
3 months ago

  • Keywords commit added

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


3 months ago

#10 @SergeyBiryukov
3 months ago

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

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.

#11 @SergeyBiryukov
3 months 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.