Repository navigation
Commit b0d2ba0
committed
fix(router): require outlets to match a route before processing child segments
Previously, empty-path outlet groups in a request URL (such as `x:/(detail:2)`,
`///(detail:2)`, or `x:/()`) were allowed to match without a corresponding
route for that outlet name in the route configuration:
1. `processChildren` called `processSegmentGroup` for each child outlet,
which immediately delegated any zero-segment group with children back to
`processChildren` against the same parent `config` and `parentRoute`
without matching a route. Calling `processSegment` directly in
`processChildren` ensures only the root `UrlSegmentGroup` short-circuits
to `processChildren`.
2. `processSegmentAgainstRoute` allowed named outlets to pierce empty-path
routes for other outlets even when the route had no children to pierce into
or the URL segment group had no segments or children to pierce with.
3. `matchSegmentAgainstRoute` branched into `processChildren` or returned a
completed leaf match before `getOutlet(route) === outlet` was satisfied,
and did not require a descendant `TreeNode` match when piercing an
empty-path route for a different outlet.
4. `noLeftoversInUrl` only checked `!segmentGroup.children[outlet]` rather
than `!segmentGroup.hasChildren()`, allowing unmatched zero-segment outlet
groups with child outlets for other names to be treated as having no
leftovers instead of throwing `NoMatch`.
Together, these allowed crafted URLs with unconfigured zero-segment outlet
groups to fan out across empty-path routes (#70932) or repeatedly evaluate
guards and construct duplicate route snapshot subtrees across sibling outlets
(#70997). Requiring every child segment group to match a route for its outlet
before unwrapping children or completing a match prevents the invalid matches
at the source.
Fixes #70932
Fixes #709971 parent 83944fc commit b0d2ba0
3 files changed
Lines changed: 184 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
227 | 235 | | |
228 | | - | |
229 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
230 | 240 | | |
231 | | - | |
| 241 | + | |
232 | 242 | | |
233 | 243 | | |
234 | 244 | | |
| |||
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
311 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
312 | 327 | | |
313 | 328 | | |
314 | 329 | | |
| |||
457 | 472 | | |
458 | 473 | | |
459 | 474 | | |
460 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
461 | 478 | | |
462 | 479 | | |
463 | 480 | | |
464 | 481 | | |
465 | 482 | | |
466 | 483 | | |
467 | 484 | | |
468 | | - | |
| 485 | + | |
469 | 486 | | |
470 | 487 | | |
471 | 488 | | |
472 | | - | |
473 | 489 | | |
474 | 490 | | |
475 | 491 | | |
| |||
487 | 503 | | |
488 | 504 | | |
489 | 505 | | |
490 | | - | |
491 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
492 | 511 | | |
493 | 512 | | |
494 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
581 | 730 | | |
582 | 731 | | |
583 | 732 | | |
| |||
810 | 959 | | |
811 | 960 | | |
812 | 961 | | |
813 | | - | |
| 962 | + | |
814 | 963 | | |
815 | 964 | | |
816 | 965 | | |
| |||
836 | 985 | | |
837 | 986 | | |
838 | 987 | | |
839 | | - | |
840 | 988 | | |
841 | 989 | | |
842 | 990 | | |
| |||
846 | 994 | | |
847 | 995 | | |
848 | 996 | | |
849 | | - | |
| 997 | + | |
850 | 998 | | |
851 | 999 | | |
852 | 1000 | | |
853 | 1001 | | |
854 | 1002 | | |
855 | 1003 | | |
856 | 1004 | | |
857 | | - | |
| 1005 | + | |
858 | 1006 | | |
859 | 1007 | | |
860 | 1008 | | |
861 | | - | |
| 1009 | + | |
862 | 1010 | | |
863 | | - | |
| 1011 | + | |
864 | 1012 | | |
865 | 1013 | | |
866 | 1014 | | |
| |||
0 commit comments