Skip to content

Fix #37488 don't emit from_template_ option when template id is empty#38702

Merged
eldy merged 1 commit into
Dolibarr:23.0from
Dolicraft:fix/37488-formmail-from-template-id-guard
Jun 11, 2026
Merged

Fix #37488 don't emit from_template_ option when template id is empty#38702
eldy merged 1 commit into
Dolibarr:23.0from
Dolicraft:fix/37488-formmail-from-template-id-guard

Conversation

@pixodeo

@pixodeo pixodeo commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

When $arraydefaultmessage->email_from is set but $arraydefaultmessage->id is empty, FormMail::showForm() built a from_template_ option key with no trailing id, and the same string was passed as the preselected value of the fromtype select. The downstream parser at htdocs/core/actions_sendmails.inc.php:337 matches /from_template_(\d+)/ (requires at least one digit) so the match failed, the SQL WHERE rowid = 0 returned nothing, and the from address fell through to the generic else branch - matching what the reporter saw.

Guard the option emission and the selected-value computation against an empty $arraydefaultmessage->id so the malformed key is never produced. Keeps the existing parser regex tight rather than widening it to \d* which would have masked future bugs.

…is empty

When $arraydefaultmessage->email_from is set but $arraydefaultmessage->id
is empty, FormMail built a 'from_template_' option key with no trailing
id, and the same string was passed as the preselected value of the
fromtype select. The downstream parser in core/actions_sendmails.inc.php
matches /from_template_(\d+)/ which requires at least one digit, so the
match failed and the from address fell back through the else branch.

Guard the option emission and the selected-value computation against
empty $arraydefaultmessage->id so the malformed key is never produced.

Signed-off-by: Dolicraft <contact@dolicraft.com>
@eldy eldy merged commit 163b18e into Dolibarr:23.0 Jun 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants