From 72119f4c6a1fff5210487eedd219f5b07ec12cf4 Mon Sep 17 00:00:00 2001 From: Nicolas Vega Date: Fri, 8 Dec 2023 02:39:36 -0300 Subject: [PATCH] Encode css & check double encoding --- php/admin/options-page-style-tab.php | 4 ++-- php/classes/class-qmn-quiz-manager.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/php/admin/options-page-style-tab.php b/php/admin/options-page-style-tab.php index 038ddf4cf..02b0ed6c4 100644 --- a/php/admin/options-page-style-tab.php +++ b/php/admin/options-page-style-tab.php @@ -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( '#(.*?)#is', '', sanitize_textarea_field( wp_unslash( $_POST['quiz_css'] ) ) ), ENT_QUOTES ) : ''; + $quiz_style = isset( $_POST['quiz_css'] ) ? htmlspecialchars( preg_replace( '#(.*?)#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 ) ); @@ -231,7 +231,7 @@ function qsm_options_styling_tab_content() { + name="quiz_css">(.*?)#is', '', htmlspecialchars_decode( $mlw_quiz_options->quiz_stye, ENT_QUOTES) ) ); ?>
diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 4b8638c47..629d57f22 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -383,7 +383,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 .= ''; + $return_display .= ''; 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 {