Project

General

Profile

Actions

Bug #14603

closed

Incorrect WMenu path matching.

Added by Romain Mardulyn about 1 month ago. Updated 2 days ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
06/17/2026
Due date:
% Done:

0%

Estimated time:

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.

Actions #1

Updated by Romain Mardulyn about 1 month ago

  • Target version set to 4.13.4
Actions #2

Updated by Romain Mardulyn about 1 month ago

  • Description updated (diff)
Actions #3

Updated by Romain Mardulyn 30 days ago

  • Target version changed from 4.13.4 to 4.14.0
Actions #4

Updated by Romain Mardulyn 30 days ago

  • Private changed from Yes to No
Actions #5

Updated by Romain Mardulyn 30 days ago

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)
Actions #6

Updated by emil de keyser 30 days ago

  • Assignee set to emil de keyser
Actions #7

Updated by emil de keyser 17 days ago

  • Status changed from Review to Resolved
  • Assignee changed from emil de keyser to Romain Mardulyn
Actions #8

Updated by Romain Mardulyn 15 days ago

  • Status changed from Resolved to Implemented @Emweb
Actions #9

Updated by Romain Mardulyn 2 days ago

  • Status changed from Implemented @Emweb to Closed
Actions

Also available in: Atom PDF