Skip to content

Commit

Permalink
Fix escaping issues on WP.com (#2334)
Browse files Browse the repository at this point in the history
* Fix sending a message to teacher

* Add missing form tag around Edit Start Date field

* Add missing form tag around button on learner profile page

* Fix Question Description field not showing

* Fix fields not showing when adding multiline or file upload questions

* Fix Answer Feedback field not showing for certain question types

* Fix pagination on learner profile page
  • Loading branch information
donnapep committed Nov 21, 2018
1 parent c096ca7 commit fd46d79
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 16 deletions.
26 changes: 22 additions & 4 deletions includes/class-sensei-course.php
Expand Up @@ -1805,13 +1805,22 @@ public function load_user_courses_content( $user = false ) {
array_merge(
wp_kses_allowed_html( 'post' ),
array(
// Explicitly allow form tag for WP.com.
'form' => array(
'action' => array(),
'method' => array(),
),
'input' => array(
'class' => array(),
'id' => array(),
'name' => array(),
'type' => array(),
'value' => array(),
),
// Explicitly allow nav tag for WP.com.
'nav' => array(
'class' => array(),
),
)
)
);
Expand Down Expand Up @@ -1843,9 +1852,18 @@ public function load_user_courses_content( $user = false ) {

<?php
if ( '' != $complete_html ) {

echo wp_kses_post( $complete_html );

echo wp_kses(
$complete_html,
array_merge(
wp_kses_allowed_html( 'post' ),
array(
// Explicitly allow nav tag for WP.com.
'nav' => array(
'class' => array(),
),
)
)
);
} else {
?>

Expand Down Expand Up @@ -2221,7 +2239,7 @@ public function the_course_free_lesson_preview( $course_id ) {
<a href="<?php echo esc_url( get_permalink() ); ?>">
<?php esc_html_e( 'Preview this course', 'woothemes-sensei' ); ?>
</a>
-
-
<?php
// translators: Placeholder is the number of preview lessons.
echo esc_html( sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) );
Expand Down
4 changes: 4 additions & 0 deletions includes/class-sensei-learners-main.php
Expand Up @@ -319,6 +319,10 @@ protected function get_row_data( $item ) {
'data-post-type' => array(),
'data-user-id' => array(),
),
// Explicitly allow form tag for WP.com.
'form' => array(
'class' => array(),
),
'input' => array(
'class' => array(),
'type' => array(),
Expand Down
53 changes: 45 additions & 8 deletions includes/class-sensei-lesson.php
Expand Up @@ -937,13 +937,13 @@ public function quiz_panel( $quiz_id = 0 ) {
array_merge(
wp_kses_allowed_html( 'post' ),
array(
'button' => array(
'button' => array(
'class' => array(),
'data-uploader-button-text' => array(),
'data-uploader-title' => array(),
'id' => array(),
),
'input' => array(
'input' => array(
'checked' => array(),
'class' => array(),
'id' => array(),
Expand All @@ -956,13 +956,20 @@ public function quiz_panel( $quiz_id = 0 ) {
'type' => array(),
'value' => array(),
),
'option' => array(
'option' => array(
'value' => array(),
),
'select' => array(
'select' => array(
'class' => array(),
'id' => array(),
'name' => array(),
),
// Explicitly allow textarea tag for WP.com.
'textarea' => array(
'class' => array(),
'id' => array(),
'name' => array(),
'rows' => array(),
),
)
)
Expand Down Expand Up @@ -1193,13 +1200,13 @@ public function quiz_panel_question( $question_type = '', $question_counter = 0,
array_merge(
wp_kses_allowed_html( 'post' ),
array(
'button' => array(
'button' => array(
'class' => array(),
'data-uploader-button-text' => array(),
'data-uploader-title' => array(),
'id' => array(),
),
'input' => array(
'input' => array(
'checked' => array(),
'class' => array(),
'id' => array(),
Expand All @@ -1210,6 +1217,13 @@ public function quiz_panel_question( $question_type = '', $question_counter = 0,
'type' => array(),
'value' => array(),
),
// Explicitly allow textarea tag for WP.com.
'textarea' => array(
'class' => array(),
'id' => array(),
'name' => array(),
'rows' => array(),
),
)
)
);
Expand Down Expand Up @@ -1823,7 +1837,7 @@ public function quiz_panel_question_field( $question_type = '', $question_id = 0
array_merge(
wp_kses_allowed_html( 'post' ),
array(
'input' => array(
'input' => array(
'checked' => array(),
'class' => array(),
'id' => array(),
Expand All @@ -1833,6 +1847,14 @@ public function quiz_panel_question_field( $question_type = '', $question_id = 0
'type' => array(),
'value' => array(),
),
// Explicitly allow textarea tag for WP.com.
'textarea' => array(
'class' => array(),
'cols' => array(),
'id' => array(),
'name' => array(),
'rows' => array(),
),
)
)
);
Expand Down Expand Up @@ -1866,7 +1888,22 @@ public function quiz_panel_question_feedback( $question_counter = 0, $question_i
$html .= '<textarea id="' . esc_attr( $field_name ) . '" name="' . esc_attr( $field_name ) . '" rows="4" cols="40" class="answer_feedback widefat">' . esc_textarea( $feedback ) . '</textarea>';
$html .= '</p>';

return wp_kses_post( $html );
return wp_kses(
$html,
array_merge(
wp_kses_allowed_html( 'post' ),
array(
// Explicitly allow textarea tag for WP.com.
'textarea' => array(
'class' => array(),
'cols' => array(),
'id' => array(),
'name' => array(),
'rows' => array(),
),
)
)
);
}

public function question_get_answer_id() {
Expand Down
7 changes: 7 additions & 0 deletions includes/class-sensei-messages.php
Expand Up @@ -270,6 +270,13 @@ public function send_message_link( $post_id = 0, $user_id = 0 ) {
array_merge(
wp_kses_allowed_html( 'post' ),
array(
// Explicitly allow form tag for WP.com.
'form' => array(
'action' => array(),
'class' => array(),
'method' => array(),
'name' => array(),
),
'input' => array(
'class' => array(),
'name' => array(),
Expand Down
15 changes: 11 additions & 4 deletions includes/class-sensei-question.php
Expand Up @@ -168,13 +168,13 @@ public function question_edit_panel() {
array_merge(
wp_kses_allowed_html( 'post' ),
array(
'button' => array(
'button' => array(
'class' => array(),
'data-uploader-button-text' => array(),
'data-uploader-title' => array(),
'id' => array(),
),
'input' => array(
'input' => array(
'checked' => array(),
'class' => array(),
'id' => array(),
Expand All @@ -187,14 +187,21 @@ public function question_edit_panel() {
'type' => array(),
'value' => array(),
),
'option' => array(
'option' => array(
'value' => array(),
),
'select' => array(
'select' => array(
'class' => array(),
'id' => array(),
'name' => array(),
),
// Explicitly allow textarea tag for WP.com.
'textarea' => array(
'class' => array(),
'id' => array(),
'name' => array(),
'rows' => array(),
),
)
)
);
Expand Down

0 comments on commit fd46d79

Please sign in to comment.