Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/give/build/Campaigns/Blocks/CampaignComments/render.php
+++ b/give/build/Campaigns/Blocks/CampaignComments/render.php
@@ -15,6 +15,4 @@
return;
}
-$secondaryColor = esc_attr($campaign->secondaryColor ?? '#27ae60');
-
-echo (new BlockRenderController())->render($attributes, $secondaryColor);
+echo (new BlockRenderController())->render($attributes, $campaign->secondaryColor ?? '#27ae60');
--- a/give/give.php
+++ b/give/give.php
@@ -6,7 +6,7 @@
* Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
* Author: GiveWP
* Author URI: https://givewp.com/
- * Version: 4.16.0
+ * Version: 4.16.1
* Requires at least: 6.6
* Requires PHP: 7.4
* Text Domain: give
@@ -426,7 +426,7 @@
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
- define('GIVE_VERSION', '4.16.0');
+ define('GIVE_VERSION', '4.16.1');
}
// Plugin Root File.
--- a/give/includes/admin/emails/class-email-access-email.php
+++ b/give/includes/admin/emails/class-email-access-email.php
@@ -257,6 +257,7 @@
* @param int $donor_id Donor ID.
* @param string $email Donor Email.
*
+ * @since 4.16.1 Return false instead of wp_die when donor is not found.
* @since 2.0
* @access public
*
@@ -265,14 +266,8 @@
public function setup_email_notification( $donor_id, $email ) {
$donor = Give()->donors->get_donor_by( 'email', $email );
- if ( ! $donor->id ) {
- wp_die(
- esc_html__( 'Cheatin’ uh?', 'give' ),
- esc_html__( 'Error', 'give' ),
- array(
- 'response' => 400,
- )
- );
+ if ( ! is_object( $donor ) || ! $donor->id ) {
+ return false;
}
$this->recipient_email = $email;
--- a/give/includes/ajax-functions.php
+++ b/give/includes/ajax-functions.php
@@ -672,6 +672,7 @@
/**
* Send Confirmation Email For Complete Donation History Access.
*
+ * @since 4.16.1 Always return a uniform success response regardless of donor existence or throttle state.
* @since 1.8.17
*
* @return bool
@@ -689,68 +690,30 @@
}
$donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) );
- if ( Give()->email_access->can_send_email( $donor->id ) ) {
- $return = [];
- $email_sent = Give()->email_access->send_email( $donor->id, $donor->email );
-
- $return['status'] = 'success';
-
- if ( ! $email_sent ) {
- $return['status'] = 'error';
- $return['message'] = Give_Notices::print_frontend_notice(
- __( 'Unable to send email. Please try again.', 'give' ),
- false,
- 'error'
- );
- }
-
- /**
- * Filter to modify access mail send notice
- *
- * @since 2.1.3
- *
- * @param string Send notice message for email access.
- *
- * @return string $message Send notice message for email access.
- */
- $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) );
-
- $return['message'] = Give_Notices::print_frontend_notice(
- $message,
- false,
- 'success'
- );
-
- } else {
- $value = Give()->email_access->verify_throttle / 60;
- $return['status'] = 'error';
-
- /**
- * Filter to modify email access exceed notices message.
- *
- * @since 2.1.3
- *
- * @param string $message email access exceed notices message
- * @param int $value email access exceed times
- *
- * @return string $message email access exceed notices message
- */
- $message = (string) apply_filters(
- 'give_email_access_requests_exceed_notice',
- sprintf(
- __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
- sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
- ),
- $value
- );
-
- $return['message'] = Give_Notices::print_frontend_notice(
- $message,
- false,
- 'error'
- );
+ if ( is_object( $donor ) && Give()->email_access->can_send_email( $donor->id ) ) {
+ Give()->email_access->send_email( $donor->id, $donor->email );
}
+ $return = [];
+ $return['status'] = 'success';
+
+ /**
+ * Filter to modify access mail send notice
+ *
+ * @since 2.1.3
+ *
+ * @param string Send notice message for email access.
+ *
+ * @return string $message Send notice message for email access.
+ */
+ $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) );
+
+ $return['message'] = Give_Notices::print_frontend_notice(
+ $message,
+ false,
+ 'success'
+ );
+
echo json_encode( $return );
give_die();
}
--- a/give/src/Campaigns/Blocks/CampaignComments/Controller/BlockRenderController.php
+++ b/give/src/Campaigns/Blocks/CampaignComments/Controller/BlockRenderController.php
@@ -10,16 +10,18 @@
class BlockRenderController
{
/**
+ * @since 4.16.1 escape attribute values in block markup
* @since 4.0.0
*/
public function render(array $attributes, string $secondaryColor): string
{
$blockAttributes = BlockAttributes::fromArray($attributes);
- $encodedAttributes = json_encode($blockAttributes->toArray());
-
- $blockId = $blockAttributes->blockId;
-
- return "<div id='givewp-campaign-comments-block-{$blockId}' data-secondary-color='{$secondaryColor}' data-givewp-campaign-comments data-attributes='{$encodedAttributes}'></div>";
+ return sprintf(
+ "<div id='givewp-campaign-comments-block-%s' data-secondary-color='%s' data-givewp-campaign-comments data-attributes='%s'></div>",
+ esc_attr((string) $blockAttributes->blockId),
+ esc_attr($secondaryColor),
+ esc_attr((string) json_encode($blockAttributes->toArray()))
+ );
}
}
--- a/give/src/Campaigns/Blocks/CampaignComments/render.php
+++ b/give/src/Campaigns/Blocks/CampaignComments/render.php
@@ -15,6 +15,4 @@
return;
}
-$secondaryColor = esc_attr($campaign->secondaryColor ?? '#27ae60');
-
-echo (new BlockRenderController())->render($attributes, $secondaryColor);
+echo (new BlockRenderController())->render($attributes, $campaign->secondaryColor ?? '#27ae60');
--- a/give/src/Campaigns/Shortcodes/CampaignCommentsShortcode.php
+++ b/give/src/Campaigns/Shortcodes/CampaignCommentsShortcode.php
@@ -57,6 +57,7 @@
}
/**
+ * @since 4.16.1 sanitize block_id from shortcode attributes
* @since 4.5.0
*/
private function parseAttributes($atts): array
@@ -75,7 +76,7 @@
], $atts, 'givewp_campaign_comments');
return [
- 'blockId' => (string) $atts['block_id'],
+ 'blockId' => sanitize_key((string) $atts['block_id']),
'campaignId' => (int) $atts['campaign_id'],
'title' => (string) $atts['title'],
'showAnonymous' => filter_var($atts['show_anonymous'], FILTER_VALIDATE_BOOLEAN),
--- a/give/vendor/composer/installed.php
+++ b/give/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'impress-org/give',
- 'pretty_version' => '4.16.0',
- 'version' => '4.16.0.0',
- 'reference' => '00d2329461c83bc4f0e30b2a14318ab09baab4d3',
+ 'pretty_version' => '4.16.1',
+ 'version' => '4.16.1.0',
+ 'reference' => 'fdda404b7e9d021966f10cb0da1e6b58bd88ec3c',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -20,9 +20,9 @@
'dev_requirement' => false,
),
'impress-org/give' => array(
- 'pretty_version' => '4.16.0',
- 'version' => '4.16.0.0',
- 'reference' => '00d2329461c83bc4f0e30b2a14318ab09baab4d3',
+ 'pretty_version' => '4.16.1',
+ 'version' => '4.16.1.0',
+ 'reference' => 'fdda404b7e9d021966f10cb0da1e6b58bd88ec3c',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),