PerlDancer / PerlDancer/Dancer2

Serializer::JSON: deserialize ignores engine config that serialize honours

Open
#1,815 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/Serializer/JSON.pm:50-57. serialize merges $self->config into its options (lines 39-41); deserialize does not — it only sets utf8 and deletes strict_utf8.

So allow_nonref and every other configured option apply in one direction only, despite being configured in one place. That is surprising and undocumented.

Suggested fix

Mirror the merge loop from serialize, but be deliberate about which options are safe to honour on the decode side. Blindly forwarding every config key to the decoder could enable options nobody intended, so an allowlist is probably right.

Worth explicitly supporting max_depth and max_size as hardening while in there — JSON::XS defaults to max_depth 512 and max_size 0 (unlimited), and neither is currently settable from Dancer2 config.

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 in lib/Dancer2/Serializer/JSON.pm at lines 39-41 and 50-57, comparing how serialize merges $self->config with how deserialize builds its options. Identify which configured decoder options are safe to allow, including max_depth and max_size. Done means supported configuration affects deserialization consistently without forwarding unsafe or unintended keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.