From 1b33eed2aa72b36695351d72111aa7dd6c597f8f Mon Sep 17 00:00:00 2001 From: Bloke Date: Wed, 28 Feb 2024 23:43:08 +0000 Subject: [PATCH] Add replyto attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks, René. --- CHANGELOG.textile | 6 ++++++ README.textile | 5 +++++ com_connect.php | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index c3ef7b5..0df78fb 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -1,5 +1,11 @@ h1. Changelog +h2. 4.7.1 - 2024-02-28 + +* Use self-closing tags to keep validators happy (thanks, jools-r). +* Fix for concatenated headers/line endings on some servers (thanks, hidalgo, Kjeld, Gallex, and phiw13). +* Add @replyto@ attribute. + h2. 4.7.0 - 2022-01-28 * Fix a few PHP 8.x warnings. diff --git a/README.textile b/README.textile index 01280d0..f43e370 100644 --- a/README.textile +++ b/README.textile @@ -193,6 +193,11 @@ h4. Attributes : Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@. ; @redirect="URL"@ : Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@. +; @replyto=boolean|email address@ +: Governs the email address of who the message reply should go to. Options: +: @true@ (default): Use the email address from the form itself (value from the @@ tag) if the @from@ address has been specified. Blank otherwise. +: @false@: Always use the @from@ email address as reply-to. Note that if the @from@ is omitted the email will be from nobody and may be rejected by the receiving server. +: @email address@: Use the specified email address as the reply-to, if it's a valid address. ; @required="boolean"@ : Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@. ; @send_article="boolean"@ diff --git a/com_connect.php b/com_connect.php index 759d968..ccffb6b 100644 --- a/com_connect.php +++ b/com_connect.php @@ -317,6 +317,7 @@ function com_connect($atts, $thing = '') 'label' => null, 'browser_validate' => 1, 'redirect' => '', + 'replyto' => true, 'required' => '1', 'show_error' => 1, 'show_input' => 1, @@ -532,8 +533,18 @@ function com_connect($atts, $thing = '') $com_connect_flags['charset'] = $override_email_charset ? 'ISO-8859-1' : 'UTF-8'; $com_connect_flags['content_type'] = 'text/plain'; $com_connect_flags['xfer_encoding'] = '8bit'; - $reply = com_connect_strip($from ? $com_connect_from : ''); - $from = com_connect_strip($from ? $from : $com_connect_from); + + if ($replyto === true) { + $reply = com_connect_strip($from ? $com_connect_from : ''); + $from = com_connect_strip($from ? $from : $com_connect_from); + } elseif ($replyto === false || !is_valid_email($replyto)) { + $reply = com_connect_strip($from ? $from : ''); + $from = com_connect_strip($from ? $from : ''); + } else { + $reply = com_connect_strip($replyto); + $from = com_connect_strip($from ? $from : $replyto); + } + $to = com_connect_strip($to); $subject = com_connect_strip($subject); $body = implode("\n\n", $msg); @@ -2344,6 +2355,11 @@ function com_connect_fields($atts, $thing = '') : Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@. ; @redirect="URL"@ : Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@. +; @replyto=boolean|email address@ +: Governs the email address of who the message reply should go to. Options: +: @true@ (default): Use the email address from the form itself (value from the @@ tag) if the @from@ address has been specified. Blank otherwise. +: @false@: Always use the @from@ email address as reply-to. Note that if the @from@ is omitted the email will be from nobody and may be rejected by the receiving server. +: @email address@: Use the specified email address as the reply-to, if it's a valid address. ; @required="boolean"@ : Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@. ; @send_article="boolean"@