Ticket #3973: unfiltered_html_xsrf_xss.diff
| File unfiltered_html_xsrf_xss.diff, 8.7 KB (added by markjaquith, 5 years ago) |
|---|
-
trunk/wp-comments-post.php
25 25 26 26 // If the user is logged in 27 27 $user = wp_get_current_user(); 28 if ( $user->ID ) :28 if ( $user->ID ) { 29 29 $comment_author = $wpdb->escape($user->display_name); 30 30 $comment_author_email = $wpdb->escape($user->user_email); 31 31 $comment_author_url = $wpdb->escape($user->user_url); 32 else : 32 if ( current_user_can('unfiltered_html') ) { 33 if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) { 34 kses_remove_filters(); // start with a clean slate 35 kses_init_filters(); // set up the filters 36 } 37 } 38 } else { 33 39 if ( get_option('comment_registration') ) 34 40 wp_die( __('Sorry, you must be logged in to post a comment.') ); 35 endif; 41 } 36 42 37 43 $comment_type = ''; 38 44 -
trunk/wp-includes/default-filters.php
31 31 add_filter('pre_comment_author_email', 'wp_filter_kses'); 32 32 add_filter('pre_comment_author_url', 'wp_filter_kses'); 33 33 34 add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); 35 34 36 // Default filters for these functions 35 37 add_filter('comment_author', 'wptexturize'); 36 38 add_filter('comment_author', 'convert_chars'); -
trunk/wp-includes/functions.php
1000 1000 return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); 1001 1001 } 1002 1002 1003 function wp_nonce_field($action = -1) { 1004 echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />'; 1005 wp_referer_field(); 1003 function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true) { 1004 $name = attribute_escape($name); 1005 echo '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce($action) . '" />'; 1006 if ( $referer ) 1007 wp_referer_field(); 1006 1008 } 1007 1009 1008 1010 function wp_referer_field() { -
trunk/wp-includes/comment-template.php
271 271 return false; 272 272 } 273 273 274 function wp_comment_form_unfiltered_html_nonce() { 275 global $post; 276 if ( current_user_can('unfiltered_html') ) 277 wp_nonce_field('unfiltered-html-comment_' . $post->ID, '_wp_unfiltered_html_comment', false); 278 } 279 274 280 function comments_template( $file = '/comments.php' ) { 275 281 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 276 282 -
branches/2.0/wp-comments-post.php
25 25 26 26 // If the user is logged in 27 27 $user = wp_get_current_user(); 28 if ( $user->ID ) :28 if ( $user->ID ) { 29 29 $comment_author = $wpdb->escape($user->display_name); 30 30 $comment_author_email = $wpdb->escape($user->user_email); 31 31 $comment_author_url = $wpdb->escape($user->user_url); 32 else : 32 if ( current_user_can('unfiltered_html') ) { 33 if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) { 34 kses_remove_filters(); // start with a clean slate 35 kses_init_filters(); // set up the filters 36 } 37 } 38 } else { 33 39 if ( get_option('comment_registration') ) 34 40 die( __('Sorry, you must be logged in to post a comment.') ); 35 endif; 41 } 36 42 37 43 $comment_type = ''; 38 44 -
branches/2.0/wp-includes/default-filters.php
33 33 add_filter('pre_comment_author_email', 'wp_filter_kses'); 34 34 add_filter('pre_comment_author_url', 'wp_filter_kses'); 35 35 36 add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); 37 36 38 // Default filters for these functions 37 39 add_filter('comment_author', 'wptexturize'); 38 40 add_filter('comment_author', 'convert_chars'); -
branches/2.0/wp-includes/functions.php
2372 2372 return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); 2373 2373 } 2374 2374 2375 function wp_nonce_field($action = -1) { 2376 echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />'; 2377 wp_referer_field(); 2375 function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true) { 2376 $name = attribute_escape($name); 2377 echo '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce($action) . '" />'; 2378 if ( $referer ) 2379 wp_referer_field(); 2378 2380 } 2379 2381 2380 2382 function wp_referer_field() { -
branches/2.0/wp-includes/comment-functions.php
2 2 3 3 // Template functions 4 4 5 function wp_comment_form_unfiltered_html_nonce() { 6 global $post; 7 if ( current_user_can('unfiltered_html') ) 8 wp_nonce_field('unfiltered-html-comment_' . $post->ID, '_wp_unfiltered_html_comment', false); 9 } 10 5 11 function comments_template( $file = '/comments.php' ) { 6 12 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 7 13 -
branches/2.1/wp-comments-post.php
25 25 26 26 // If the user is logged in 27 27 $user = wp_get_current_user(); 28 if ( $user->ID ) :28 if ( $user->ID ) { 29 29 $comment_author = $wpdb->escape($user->display_name); 30 30 $comment_author_email = $wpdb->escape($user->user_email); 31 31 $comment_author_url = $wpdb->escape($user->user_url); 32 else : 32 if ( current_user_can('unfiltered_html') ) { 33 if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) { 34 kses_remove_filters(); // start with a clean slate 35 kses_init_filters(); // set up the filters 36 } 37 } 38 } else { 33 39 if ( get_option('comment_registration') ) 34 40 wp_die( __('Sorry, you must be logged in to post a comment.') ); 35 endif; 41 } 36 42 37 43 $comment_type = ''; 38 44 -
branches/2.1/wp-includes/default-filters.php
31 31 add_filter('pre_comment_author_email', 'wp_filter_kses'); 32 32 add_filter('pre_comment_author_url', 'wp_filter_kses'); 33 33 34 add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); 35 34 36 // Default filters for these functions 35 37 add_filter('comment_author', 'wptexturize'); 36 38 add_filter('comment_author', 'convert_chars'); -
branches/2.1/wp-includes/functions.php
920 920 return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); 921 921 } 922 922 923 function wp_nonce_field($action = -1) { 924 echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />'; 925 wp_referer_field(); 923 function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true) { 924 $name = attribute_escape($name); 925 echo '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce($action) . '" />'; 926 if ( $referer ) 927 wp_referer_field(); 926 928 } 927 929 928 930 function wp_referer_field() { -
branches/2.1/wp-includes/comment-template.php
271 271 return false; 272 272 } 273 273 274 function wp_comment_form_unfiltered_html_nonce() { 275 global $post; 276 if ( current_user_can('unfiltered_html') ) 277 wp_nonce_field('unfiltered-html-comment_' . $post->ID, '_wp_unfiltered_html_comment', false); 278 } 279 274 280 function comments_template( $file = '/comments.php' ) { 275 281 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity; 276 282
