Changeset 19982 for trunk/wp-admin/includes/media.php
- Timestamp:
- 02/24/2012 01:58:18 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/media.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r19871 r19982 150 150 $width = $matches[1]; 151 151 152 $caption = str_replace( array( '>', '<', '"', "'" ), 153 array( '>', '<', '"', ''' ), 154 $caption 155 ); 152 $caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption ); 153 $caption = str_replace( '"', '"', $caption ); 156 154 157 155 $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); … … 160 158 161 159 $shcode = '[caption id="' . $id . '" align="align' . $align 162 . '" width="' . $width . '" caption="' . addslashes($caption). '"]' . $html . '[/caption]';160 . '" width="' . $width . '" caption="' . $caption . '"]' . $html . '[/caption]'; 163 161 164 162 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); 165 163 } 166 164 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); 165 166 // Private, preg_replace callback used in image_add_caption() 167 function _cleanup_image_add_caption($str) { 168 if ( isset($str[0]) ) 169 return str_replace( '"', "'", $str[0] ); 170 171 return ''; 172 } 167 173 168 174 /** … … 777 783 return " 778 784 <input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> 779 <button type='button' class='button urlnone' title=''>" . __('None') . "</button>780 <button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>781 <button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>785 <button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button> 786 <button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button> 787 <button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button> 782 788 "; 789 } 790 791 function wp_caption_input_textarea($edit_post) { 792 // post data is already escaped 793 $name = "attachments[{$edit_post->ID}][post_excerpt]"; 794 795 return ' 796 <textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea> 797 <div class="edit-caption-controls hide-if-no-js"> 798 <input type="button" class="button caption-insert-link" value="' . esc_attr__('Insert Link') . '" /> 799 <div class="caption-insert-link-wrap hidden"> 800 <label><span>' . __('Link URL') . '</span> 801 <input type="text" value="" class="caption-insert-link-url" /></label> 802 <label><span>' . __('Linked text') . '</span> 803 <input type="text" value="" class="caption-insert-link-text" /></label> 804 <div class="caption-insert-link-buttons"> 805 <input type="button" class="button caption-cancel" value="' . esc_attr__('Cancel') . '" /> 806 <input type="button" class="button-primary caption-save" value="' . esc_attr__('Insert') . '" /> 807 <br class="clear" /> 808 </div></div></div> 809 '; 783 810 } 784 811 … … 925 952 'image_alt' => array(), 926 953 'post_excerpt' => array( 927 'label' => __('Caption'), 928 'value' => $edit_post->post_excerpt 954 'label' => __('Default Caption'), 955 'input' => 'html', 956 'html' => wp_caption_input_textarea($edit_post) 929 957 ), 930 958 'post_content' => array( … … 1203 1231 $item .= $field[ $field['input'] ]; 1204 1232 elseif ( $field['input'] == 'textarea' ) { 1205 if ( user_can_richedit() ) { // textarea_escaped when user_can_richedit() = false 1206 $field['value'] = esc_textarea( $field['value'] ); 1233 if ( 'post_content' == $id && user_can_richedit() ) { 1234 // sanitize_post() skips the post_content when user_can_richedit 1235 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); 1207 1236 } 1237 // post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit() 1208 1238 $item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>'; 1209 1239 } else { … … 1514 1544 1515 1545 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1516 if ( f.caption.value ) 1517 caption = f.caption.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 1546 if ( f.caption.value ) { 1547 caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){ 1548 return a.replace(/"/g, "'"); 1549 }); 1550 1551 caption = caption.replace(/"/g, '"'); 1552 } 1518 1553 <?php } ?> 1519 1554
Note: See TracChangeset
for help on using the changeset viewer.