Error with regex in `Str::placeholders`

Open
#37 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
backend

Research direction

Start with the placeholders method in bolt/common and reproduce the failure using the Bolt/Forms notification configuration and fields shown in the issue. Verify the regular expression's handling of replyto_email: email and replyto_name: lastname; done means the form renders without the RFC 2822 validation error.

Written by the indexing model from the issue text.

Description

Hello,

I'm reporting an error I detected when I wanted to use in Bolt/Forms extension, parameters replyto_email and replyto_name.

The form returns me an error:

"An exception has been thrown during the rendering of a template ("Email "email" does not comply with addr-spec of RFC 2822.")."

After debugging, it turns out that the error comes from bolt/common, in the placeholders method.

The regexp doesn't seem to be good at detecting the string sent to it.

Example to reproduce the bug:

  1. Install last bolt version
  2. Install last bolt/forms version
  3. Create form with notification parameters like that :
notification:
        enabled: true
        debug: false
        debug_address: name@example.com # Email address used when debug mode is enabled
        debug_smtp: true
        subject: New contact
        subject_prefix: '[XXX]'
        to_name: 'John'
        to_email: 'john.doe@example.com'
        from_name: 'James'
        from_email: 'james.bond@example.com'
        replyto_name: lastname
        replyto_email: email
  1. Add two fields
lastname:
            type: text
            fieldLabel: Nom
            options:
                required: true
                label: Lastname
                constraints: [ NotBlank ]
                attr:
                    placeholder: Nom
email:
            type: email
            fieldLabel: Email
            options:
                required: true
                constraints: [ NotBlank, Email ]
                attr:
                    placeholder: Email
  1. Test form
  2. Error appear

Here a pr to fix it (works for me)

Dominant language
PHP
Stars
18
Forks
6
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.