Skip to content

Commit

Permalink
Merge pull request #2413 from nicolasvegaabril/bugfix/double-encoding
Browse files Browse the repository at this point in the history
[ Issue #2412 ] Encode css & check double encoding
  • Loading branch information
zubairraeen authored Dec 12, 2023
2 parents 8c718f8 + 72119f4 commit d7f8294
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions php/admin/options-page-style-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function qsm_options_styling_tab_content() {

$style_quiz_id = isset( $_POST['style_quiz_id'] ) ? intval( $_POST['style_quiz_id'] ) : '';
$quiz_theme = isset( $_POST['save_quiz_theme'] ) ? sanitize_text_field( wp_unslash( $_POST['save_quiz_theme'] ) ) : '';
$quiz_style = isset( $_POST['quiz_css'] ) ? htmlspecialchars( preg_replace( '#<script(.*?)>(.*?)</script>#is', '', sanitize_textarea_field( wp_unslash( $_POST['quiz_css'] ) ) ), ENT_QUOTES ) : '';
$quiz_style = isset( $_POST['quiz_css'] ) ? htmlspecialchars( preg_replace( '#<script(.*?)>(.*?)</script>#is', '', sanitize_textarea_field( wp_unslash( $_POST['quiz_css'] ) ) ), ENT_QUOTES, 'UTF-8', false) : '';

// Saves the new css.
$results = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}mlw_quizzes SET quiz_stye=%s, theme_selected=%s, last_activity=%s WHERE quiz_id=%d", $quiz_style, $quiz_theme, gmdate( 'Y-m-d H:i:s' ), $style_quiz_id ) );
Expand Down Expand Up @@ -231,7 +231,7 @@ function qsm_options_styling_tab_content() {
<table class="form-table">
<tr>
<td><textarea style="width: 100%; height: 700px;" id="quiz_css"
name="quiz_css"><?php echo esc_textarea( preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $mlw_quiz_options->quiz_stye ) ); ?></textarea></td>
name="quiz_css"><?php echo esc_textarea( preg_replace( '#<script(.*?)>(.*?)</script>#is', '', htmlspecialchars_decode( $mlw_quiz_options->quiz_stye, ENT_QUOTES) ) ); ?></textarea></td>
</tr>
</table>
<?php wp_nonce_field( 'qsm_style_tab_nonce_action', 'qsm_style_tab_nonce' ); ?>
Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function display_shortcode( $atts ) {
wp_enqueue_style( 'dashicons' );
// The quiz_stye is misspelled because it has always been misspelled and fixing it would break many sites :(.
if ( 'default' == $qmn_quiz_options->theme_selected ) {
$return_display .= '<style type="text/css">' . preg_replace( '#<script(.*?)>(.*?)</script>#is', '', htmlspecialchars_decode( $qmn_quiz_options->quiz_stye ) ) . '</style>';
$return_display .= '<style type="text/css">' . preg_replace( '#<script(.*?)>(.*?)</script>#is', '', htmlspecialchars_decode( $qmn_quiz_options->quiz_stye, ENT_QUOTES) ) . '</style>';
wp_enqueue_style( 'qmn_quiz_style', QSM_PLUGIN_CSS_URL . '/qmn_quiz.css', array(), $mlwQuizMasterNext->version );
wp_style_add_data( 'qmn_quiz_style', 'rtl', 'replace' );
} else {
Expand Down

0 comments on commit d7f8294

Please sign in to comment.