From b71aaa4c4948ebc60bfa1c294f26fd8a53ff04ca Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Tue, 9 Jan 2024 18:00:00 +0530 Subject: [PATCH 1/2] fixed code tag issue --- php/question-types/qsm-question-title.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/php/question-types/qsm-question-title.php b/php/question-types/qsm-question-title.php index b3d2751e6..1c05daa3e 100644 --- a/php/question-types/qsm-question-title.php +++ b/php/question-types/qsm-question-title.php @@ -51,8 +51,14 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_ $allow_html['input']['id'] = 1; $allow_html['input']['maxlength'] = 1; $allow_html = apply_filters( 'qsm_allow_html_question_title_after', $allow_html, $question_id ); + $pattern = '/(.*?)<\/code>/s'; + $question_title_modified_html = preg_replace_callback($pattern, function ( $matches ) { + $replacement = preg_replace([ '/<(?!(\/?code|br)[ >])/', '/>(?!(\/?code|br)[ \/>])/' ], [ '<', '>' ], $matches[0]); + return $replacement; + }, $question_title); + $question_title_modified_html = str_replace([ 'code>', 'br />' ],[ 'code/>', 'br />' ], $question_title_modified_html ); ?> -

+

Date: Tue, 9 Jan 2024 18:05:12 +0530 Subject: [PATCH 2/2] fixed sonar issue --- php/question-types/qsm-question-title.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/php/question-types/qsm-question-title.php b/php/question-types/qsm-question-title.php index 1c05daa3e..6ae824674 100644 --- a/php/question-types/qsm-question-title.php +++ b/php/question-types/qsm-question-title.php @@ -53,8 +53,7 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_ $allow_html = apply_filters( 'qsm_allow_html_question_title_after', $allow_html, $question_id ); $pattern = '/(.*?)<\/code>/s'; $question_title_modified_html = preg_replace_callback($pattern, function ( $matches ) { - $replacement = preg_replace([ '/<(?!(\/?code|br)[ >])/', '/>(?!(\/?code|br)[ \/>])/' ], [ '<', '>' ], $matches[0]); - return $replacement; + return preg_replace([ '/<(?!(\/?code|br)[ >])/', '/>(?!(\/?code|br)[ \/>])/' ], [ '<', '>' ], $matches[0]); }, $question_title); $question_title_modified_html = str_replace([ 'code>', 'br />' ],[ 'code/>', 'br />' ], $question_title_modified_html ); ?>