Skip to content

Commit

Permalink
🔒️ Added more escaping to ensure there's no XSS attacks
Browse files Browse the repository at this point in the history
  • Loading branch information
CWDN committed Jul 16, 2024
1 parent da9863e commit b67d1ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions includes/classes/admin/mapping/field-types/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ public function e_type_id() {
}

public function option_underscore_template( View $view ) {
$option = '<option <# if ( "' . $this->type_id() . '" === data.field_type ) { #>selected="selected"<# } #> value="' . $this->type_id() . '">' . $this->option_label . '</option>';
$option = '<option <# if ( "' . esc_html($this->type_id()) . '" === data.field_type ) { #>selected="selected"<# } #> value="' . esc_html($this->type_id()) . '">' . esc_html($this->option_label) . '</option>';

if ( $types = $this->get_supported_types() ) {
$option = '<# if ( data.type in ' . $types . ' ) { #>' . $option . '<# } #>';
}

/**
* This is not escaped as it can contain various tags that we know are safe.
* We force strip the script tags to avoid as XSS attacks.
* We are unable to use wp_kses as it doesn't handle the <# #> tags correctly and strips the end tag.
*/
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo "\n\t" . $option;
echo "\n\t" . preg_replace("/<script.*?\/script>/s", "", $option)
}

public function underscore_options( $array ) {
Expand Down

0 comments on commit b67d1ef

Please sign in to comment.