Skip to content

Fix GroupPosBased dispatching when a placeholder matches the empty string - #309

Open
jimbou wants to merge 1 commit into
nikic:masterfrom
jimbou:fix-groupposbased-empty-match
Open

jimbou wants to merge 1 commit into
nikic:masterfrom
jimbou:fix-groupposbased-empty-match

Conversation

@jimbou

@jimbou jimbou commented Nov 7, 2026

Copy link
Copy Markdown

GroupPosBased identified the matched route by the first non-empty capture group, so a group that matched the empty string was skipped. The request went to the next route's handler, or ended in a TypeError when there was none. Use PREG_UNMATCHED_AS_NULL and pick the first group that is not null.

Adds two regression cases to DispatcherTestCase, so they run for all four strategies. They fail on master for GroupPosBased only; with this change the full suite passes.

Fixes #307

…ring

GroupPosBased identified the matched route by the first non-empty capture group, so a group that matched the empty string was skipped. The request went to the next route's handler, or ended in a TypeError when there was none. Use PREG_UNMATCHED_AS_NULL and pick the first group that is not null.

Fixes nikic#307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GroupPosBased picks the wrong route when a placeholder matches the empty string

1 participant