[wp-trac] [WordPress Trac] #60916: Menu link validation

WordPress Trac noreply at wordpress.org
Thu Jun 13 23:03:42 UTC 2024


#60916: Menu link validation
-------------------------------------+-------------------------------------
 Reporter:  nikitasolanki1812        |       Owner:  rcreators
     Type:  defect (bug)             |      Status:  assigned
 Priority:  normal                   |   Milestone:  6.6
Component:  Menus                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch changes-       |     Focuses:  javascript,
  requested                          |  administration
-------------------------------------+-------------------------------------

Comment (by ironprogrammer):

 Thank you, everyone, for keeping on with this ticket! In my testing I
 found a regression and a couple of things that should be addressed
 (possibly in another ticket).

 == Test Report
 Patch tested: https://github.com/WordPress/wordpress-develop/pull/6389

 === Steps to Reproduce or Test
 1. Setup: With a classic theme active that supports menus, set up a new
 menu and add links using ''Add menu items > Custom Links'':
         1. Add link with valid URL. Should be added to menu.
         1. Add link with hash (e.g. `#content`). Should be added to menu.
         1. Add link with random text that isn't a URL. Should be added to
 menu, prepended by `http://`.
         1. Try using a space for URL, confirm validation occurs. Cannot
 add.
         1. Save menu. Should include the three items successfully added
 above.
 1. Test using ''Menu structure'' to modify links directly:
         1. Replace URL with a space in one of the links.
         1. Save menu and observe modified link's URL.
         1. Save menu again and observe modified link's URL (expect this
 should be unchanged). **Make note of this link and do not modify it before
 applying patch.**
         1. [Optional] Add valid URL, save, remove URL, save. Should be
 same as above.

 === Expected Results
 When reproducing the bug:
 - ❌ Links with blank or unset (`http://` or `https://`) URLs are not
 validated and can be saved.

 When testing a patch to validate it works as expected:
 - ✅ Links with blank or unset (`http://` or `https://`) URLs are
 validated, indicating an error.
 - ✅ Links with validation errors prevent saving the menu.

 === Environment
 - Hardware: MacBook Pro Apple M1 Pro
 - OS: macOS 14.5
 - Browser: Safari 17.5
 - Server: nginx/1.27.0
 - PHP: 8.2.20
 - MySQL: 8.0.27
 - WordPress: 6.6-alpha-57778-src
 - Theme: twentytwentyone v2.2

 ==== Actual Results
 - Apply patch and run `npm run build:dev`.
 - Refresh page and make sure the modified blank URL link from above
 exists.
 - Using ''Menu structure'' to modify links directly:
         - ✅ Expand the link with a blank URL, observe that field displays
 placeholder (`https://`).
         - ❌ Observe that field does NOT reflect validation.
         - ❌ Save menu without making any changes. Link with blank URL
 disappears. (Regression: Should not delete links with invalid URL, as they
 could be unintentionally deleted after patch or WP upgrade.)
         - ✅ Delete the URL from one of the other links, confirm
 validation occurs. Cannot save.
         - ⚠️ Enter a space in the URL field, confirm NO validation occurs.
 (Consistent with before patch; but does not match validation of Custom
 Links adder.)
         - Save menu. Items should include link just modified.
         - ⚠️ Expand blank URL link, observe space has been removed,
 showing placeholder text, confirm NO validation occurs. (Consistent with
 before patch.)
         - ❌ Save menu. Blank URL link disappears. (Regression like above:
 Should not delete links with invalid URL.)
         - ✅ Delete URL from remaining link, confirm validation occurs.
         - ✅ Try entering `http://` or `https://`, confirm validation
 occurs.

 === Supplemental Artifacts
 - Video demonstrating regression and inconsistency of validating for
 spaces as URL: https://cloudup.com/c-z6eNQLPfb.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60916#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list