WordPress.org

Make WordPress Core

Ticket #15454: garyc40-15454.patch

File garyc40-15454.patch, 3.7 KB (added by garyc40, 10 years ago)

fixed various double escaping issues

  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index 33e7867..9038888 100644
    function get_media_item( $attachment_id, $args = null ) { 
    13431343                if ( !empty( $field[ $field['input'] ] ) )
    13441344                        $item .= $field[ $field['input'] ];
    13451345                elseif ( $field['input'] == 'textarea' ) {
    1346                         $item .= "<textarea type='text' id='$name' name='$name' $aria_required>" . esc_textarea( $field['value'] ) . '</textarea>';
     1346                        if ( user_can_richedit() ) { // already escaped when user_can_richedit() = false
     1347                                $field['value'] = esc_textarea( $field['value'] );
     1348                        }
     1349                        $item .= "<textarea type='text' id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>';
    13471350                } else {
    13481351                        $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />";
    13491352                }
  • wp-admin/includes/meta-boxes.php

    diff --git wp-admin/includes/meta-boxes.php wp-admin/includes/meta-boxes.php
    index 42678db..96466b5 100644
    function post_tags_meta_box($post, $box) { 
    288288        <div class="jaxtag">
    289289        <div class="nojs-tags hide-if-js">
    290290        <p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
    291         <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo esc_textarea( get_terms_to_edit( $post->ID, $tax_name ) ); ?></textarea></div>
     291        <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo get_terms_to_edit( $post->ID, $tax_name ); // escaped by esc_attr() ?></textarea></div>
    292292        <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
    293293        <div class="ajaxtag hide-if-no-js">
    294294                <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
    function link_advanced_meta_box($link) { 
    892892        </tr>
    893893        <tr class="form-field">
    894894                <th valign="top"  scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
    895                 <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo esc_textarea( ( isset( $link->link_notes ) ? $link->link_notes : '') ); ?></textarea></td>
     895                <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // escaped ?></textarea></td>
    896896        </tr>
    897897        <tr class="form-field">
    898898                <th valign="top"  scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
  • wp-includes/bookmark.php

    diff --git wp-includes/bookmark.php wp-includes/bookmark.php
    index ddb5e13..b99a719 100644
    function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { 
    334334                return $value;
    335335
    336336        if ( 'edit' == $context ) {
    337                 $format_to_edit = array('link_notes');
    338337                $value = apply_filters("edit_$field", $value, $bookmark_id);
    339 
    340                 if ( in_array($field, $format_to_edit) ) {
    341                         $value = format_to_edit($value);
    342                 } else {
    343                         $value = esc_attr($value);
    344                 }
     338                $value = esc_attr( $value );
    345339        } else if ( 'db' == $context ) {
    346340                $value = apply_filters("pre_$field", $value);
    347341        } else {
  • wp-includes/formatting.php

    diff --git wp-includes/formatting.php wp-includes/formatting.php
    index 82ce377..2f93cda 100644
    function force_balance_tags( $text ) { 
    11261126function format_to_edit($content, $richedit = false) {
    11271127        $content = apply_filters('format_to_edit', $content);
    11281128        if (! $richedit )
    1129                 $content = htmlspecialchars($content);
     1129                $content = esc_textarea($content);
    11301130        return $content;
    11311131}
    11321132