Skip to content

Commit 5c25c7d

Browse files
authored
Merge pull request #227 from brainstormforce/fix/information-disclosure
fix: prevent information disclosure in error handling
2 parents 911fd1a + fb7495d commit 5c25c7d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

functions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,10 @@ function display_rich_snippet( $content ) {
883883
$datetime = new DateTime( $video_date, new DateTimeZone( $timezone ) ); // Set the timezone to the server's timezone.
884884
$uploadDate = $datetime->format( 'd-m-Y\TH:i:sP' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
885885
} catch ( Exception $e ) {
886-
// Translators: %s is the error message from the exception.
887-
echo esc_html( sprintf( __( 'Error creating DateTime object: %s', 'rich-snippets' ), esc_html( $e->getMessage() ) ) );
888-
return;
886+
// Log the error instead of displaying it to frontend visitors.
887+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
888+
error_log( 'AIOSRS: Error creating DateTime object: ' . $e->getMessage() );
889+
return $content;
889890
}
890891
}
891892
}

init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function bsf_oembed_ajax_results() {
669669
$fallback = $wp_embed->maybe_make_link( $oembed_url );
670670
if ( $check_embed && $check_embed != $fallback ) {
671671
// Embed data.
672-
$return = '<div class="embed_status">' . $check_embed . '<a href="#" class="bsf_remove_file_button" rel="' . esc_attr( $_REQUEST['field_id'] ) . '">' . __( 'Remove Embed', 'rich-snippets' ) . '</a></div>';
672+
$return = '<div class="embed_status">' . $check_embed . '<a href="#" class="bsf_remove_file_button" rel="' . esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['field_id'] ) ) ) . '">' . __( 'Remove Embed', 'rich-snippets' ) . '</a></div>';
673673
// set our response id.
674674
$found = 'found';
675675
} else {

0 commit comments

Comments
 (0)