Changeset 20114 for trunk/wp-admin/includes/media.php
- Timestamp:
- 03/05/2012 07:31:31 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r19999 r20114 150 150 $width = $matches[1]; 151 151 152 $caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption ); 152 // look only for html tags with attributes 153 $caption = preg_replace_callback( '/<[a-zA-Z0-9]+ [^<>]+>/', '_cleanup_image_add_caption', $caption ); 153 154 $caption = str_replace( '"', '"', $caption ); 154 155 … … 166 167 // Private, preg_replace callback used in image_add_caption() 167 168 function _cleanup_image_add_caption($str) { 168 if ( isset($str[0]) ) 169 return str_replace( '"', "'", $str[0] ); 169 if ( isset($str[0]) ) { 170 // look for single quotes inside html attributes (for example in title) 171 $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $str[0] ); 172 return str_replace( '"', "'", $s ); 173 } 170 174 171 175 return ''; 176 } 177 178 // Private, preg_replace callback used in image_add_caption() 179 function _cleanup_image_add_caption2($str) { 180 return str_replace( "'", ''', $str ); 172 181 } 173 182 … … 796 805 $name = "attachments[{$edit_post->ID}][post_excerpt]"; 797 806 798 return ' 799 <textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea> 800 <div class="edit-caption-controls hide-if-no-js"> 801 <input type="button" class="button caption-insert-link" value="' . esc_attr__('Insert Link') . '" /> 802 <div class="caption-insert-link-wrap hidden"> 803 <label><span>' . __('Link URL') . '</span> 804 <input type="text" value="" class="caption-insert-link-url" /></label> 805 <label><span>' . __('Linked text') . '</span> 806 <input type="text" value="" class="caption-insert-link-text" /></label> 807 <div class="caption-insert-link-buttons"> 808 <input type="button" class="button caption-cancel" value="' . esc_attr__('Cancel') . '" /> 809 <input type="button" class="button-primary caption-save" value="' . esc_attr__('Insert') . '" /> 810 <br class="clear" /> 811 </div></div></div> 812 '; 807 return '<textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>'; 813 808 } 814 809 … … 1548 1543 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1549 1544 if ( f.caption.value ) { 1550 caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){ 1545 caption = f.caption.value.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){ 1546 a = a.replace(/="[^"]+"/, function(b){ 1547 return b.replace(/'/g, '''); 1548 }); 1551 1549 return a.replace(/"/g, "'"); 1552 1550 }); … … 1955 1953 <span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span> 1956 1954 </th> 1957 <td class="field">< input id="caption" name="caption" value="" type="text" /></td>1955 <td class="field"><textarea id="caption" class="code" name="caption"></textarea></td> 1958 1956 </tr> 1959 1957 ';
Note: See TracChangeset
for help on using the changeset viewer.