Skip to content

Escape route prefixes in active_for_routes before using them as regex #47

Description

@javihgil

Problem

active_for_routes() currently uses the provided prefix directly inside preg_match().

That means route prefixes containing regular expression characters can behave incorrectly or trigger unexpected matching behavior.

Current evidence

  • src/Twig/Extension/ActiveForRoutesExtension.php builds the pattern with "/^$routesStartsWith/i"
  • the input is treated as regex syntax instead of plain route text

Expected behavior

Route prefixes should be matched as route text, not as arbitrary regular expressions.

Suggested work

  • escape the user-provided prefix before building the regex
  • keep the current support for matching both the raw prefix and the admin_ prefixed variant
  • add tests for prefixes containing regex-special characters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions