Project

General

Profile

Actions

Bug #14603

closed
RM RM

Incorrect WMenu path matching.

Bug #14603: Incorrect WMenu path matching.

Added by Romain Mardulyn 3 months ago. Updated about 2 months 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.

RM Updated by Romain Mardulyn 3 months ago Actions #1

  • Target version set to 4.13.4

RM Updated by Romain Mardulyn 3 months ago Actions #2

  • Description updated (diff)

RM Updated by Romain Mardulyn 3 months ago Actions #3

  • Target version changed from 4.13.4 to 4.14.0

RM Updated by Romain Mardulyn 3 months ago Actions #4

  • Private changed from Yes to No

RM Updated by Romain Mardulyn 3 months ago Actions #5

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

ED Updated by emil de keyser 3 months ago Actions #6

  • Assignee set to emil de keyser

ED Updated by emil de keyser 2 months ago Actions #7

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

RM Updated by Romain Mardulyn 2 months ago Actions #8

  • Status changed from Resolved to Implemented @Emweb

RM Updated by Romain Mardulyn about 2 months ago Actions #9

  • Status changed from Implemented @Emweb to Closed
Actions

Also available in: PDF Atom