PerlDancer / PerlDancer/Dancer2

Route::_check_options interpolates the option name into a regex

Open Beginner friendly
#1,813 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Perl
Stars
604
Forks
288
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Status: reasoned from code

lib/Dancer2/Core/Route.pm:63:

croak "Not a valid option for route matching: `$opt'"
  if not( grep {/^$opt$/} @supported_options );

$opt is a hash key interpolated straight into a pattern.

Impact

  • An option named . matches every supported option and defeats the validation entirely.
  • An option containing regex metacharacters dies with a regex compile error instead of the intended message.
  • It recompiles a pattern per option per route.

Developer-supplied rather than request-supplied, so this is correctness rather than security.

Suggested fix

if ( not grep { $_ eq $opt } @supported_options ) {

Strictly better and faster.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/Dancer2/Core/Route.pm:63 and inspect how _check_options validates each route option. Replace the regex-based comparison with literal option-name matching, then verify that valid options still pass and invalid or regex-like names produce the intended validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.