PerlDancer / PerlDancer/Dancer2
Serializer::JSON: deserialize ignores engine config that serialize honours
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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