Skip to content

Commit

Permalink
[#869] Fix incorrectly encoded Email Subject (#871)
Browse files Browse the repository at this point in the history
* [N/A] Update Plugins to Latest Versions

* [N/A] Updated WC Stripe Gateway Plugin

* [#869] Testing Auction Title Special Characters

* [#869] Sanitize Email Subject and Auction Title
  • Loading branch information
bd-viget authored Apr 4, 2024
1 parent 27e9b34 commit 8c4d819
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function trigger( mixed $object = null, ?int $user_id = null ): void {
// Woohoo, send the email!
$this->send(
$this->get_recipient(),
$this->get_subject(),
goodbids()->utilities->sanitize_email_subject( $this->get_subject() ),
$this->get_content(),
$this->get_headers(),
$this->get_attachments()
Expand Down Expand Up @@ -439,9 +439,10 @@ private function default_placeholders(): void {
$this->add_placeholder( '{auctions_url}', get_post_type_archive_link( goodbids()->auctions->get_post_type() ) );

// Auction Details.
$auction_title = $auction?->get_title() ?: '';
$this->add_placeholder( '{auction.url}', $auction?->get_url() );
$this->add_placeholder( '{auction.admin_url}', get_edit_post_link( $auction?->get_id() ) );
$this->add_placeholder( '{auction.title}', $auction?->get_title() );
$this->add_placeholder( '{auction.title}', htmlspecialchars( $auction_title ) );
$this->add_placeholder( '{auction.start_date_time}', $auction?->get_start_date_time( $datetime_format ) );
$this->add_placeholder( '{auction.end_date_time}', $auction?->get_end_date_time( $datetime_format ) );

Expand Down
14 changes: 14 additions & 0 deletions client-mu-plugins/goodbids/src/classes/Utilities/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,18 @@ public function network_get_current_blog_id(): int {

return intval( sanitize_text_field( $_GET['id'] ) ); // phpcs:ignore
}

/**
* Sanitize Special Characters from Email Subject
*
* @since 1.0.1
*
* @param string $subject
*
* @return string
*/
public function sanitize_email_subject( string $subject ): string {
$subject = htmlspecialchars_decode( $subject );
return html_entity_decode( $subject );
}
}

0 comments on commit 8c4d819

Please sign in to comment.