Bug #14603
closedIncorrect WMenu path matching.
0%
Description
From pull request #246
Problem
WMenu uses the internal match(path, component) helper function to determine how well the current internal path matches a menu item's path component.
The current implementation incorrectly treats prefix matches as valid even when they do not end on a path segment boundary.
For example:
If the current path is /contact-us and the menu contains a "contact" item, match("contact-us", "contact") returns 7, causing the "contact" menu item to be incorrectly selected even though /contact-us represents a different route.
Likewise, match("a/ab", "a/ac") returns 1 instead of -1, which contradicts the documented behavior of the helper function.
Solution
Update match() in src/Wt/WMenu.C to enforce path-segment boundary checks.
Return a positive match only when the component is an exact match or when the following character in the path is '/'.
Add the regression test WMenu_internal_path_matching_segment_boundary in test/widgets/WMenuTest.C to prevent future regressions.
Updated by Romain Mardulyn 30 days ago
- Target version changed from 4.13.4 to 4.14.0
Updated by Romain Mardulyn 30 days ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)
Updated by emil de keyser 17 days ago
- Status changed from Review to Resolved
- Assignee changed from emil de keyser to Romain Mardulyn
Updated by Romain Mardulyn 15 days ago
- Status changed from Resolved to Implemented @Emweb
Updated by Romain Mardulyn 2 days ago
- Status changed from Implemented @Emweb to Closed