bolt / bolt/common

Error with regex in `Str::placeholders`

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
18
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm reporting an error I detected when I wanted to use in [Bolt/Forms](https://github.com/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 :

```yaml
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
```

4. Add two fields

```yaml
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
```

5. Test form
6. Error appear

Here a pr to fix it (works for me)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.