Make WordPress Core

Changeset 18992


Ignore:
Timestamp:
10/18/2011 07:32:40 PM (15 years ago)
Author:
nacin
Message:

Fix media/audio/file URL insertion. Strip slashes off title text. Leave red X to images only. fixes #14996. fixes #17578.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r18982 r18992  
    513513
    514514        if ( !empty($_POST['insertonlybutton']) ) {
    515                 $src = $_POST['insertonly']['src'];
     515                $src = $_POST['src'];
    516516                if ( !empty($src) && !strpos($src, '://') )
    517517                        $src = "http://$src";
    518518
    519519                if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
    520                         $title = esc_attr($_POST['insertonly']['title']);
    521                         if ( empty($title) )
    522                                 $title = esc_attr( basename($src) );
    523 
    524                         if ( !empty($title) && !empty($src) )
     520                        $title = esc_html( stripslashes( $_POST['title'] ) );
     521                        if ( empty( $title ) )
     522                                $title = esc_html( basename( $src ) );
     523
     524                        if ( $title && $src )
    525525                                $html = "<a href='" . esc_url($src) . "' >$title</a>";
    526526
    527527                        $type = 'file';
    528                         if ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) && $ext_type = wp_ext2type( $ext )
     528                        if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
    529529                                && ( 'audio' == $ext_type || 'video' == $ext_type ) )
    530530                                        $type = $ext_type;
    … …  
    533533                } else {
    534534                        $align = '';
    535                         $alt = esc_attr($_POST['insertonly']['alt']);
    536                         if ( isset($_POST['insertonly']['align']) ) {
    537                                 $align = esc_attr($_POST['insertonly']['align']);
     535                        $alt = esc_attr( stripslashes( $_POST['alt'] ) );
     536                        if ( isset($_POST['align']) ) {
     537                                $align = esc_attr( stripslashes( $_POST['align'] ) );
    538538                                $class = " class='align$align'";
    539539                        }
    … …  
    15181518
    15191519        getImageData : function() {
     1520                if ( jQuery('table.describe').hasClass('not-image') )
     1521                        return;
     1522
    15201523                var t = addExtImage, src = document.forms[0].src.value;
    15211524
    1522                 if ( ! src || jQuery('table.describe').hasClass('not-image') ) {
     1525                if ( ! src ) {
    15231526                        t.resetImageData();
    15241527                        return false;
Note: See TracChangeset for help on using the changeset viewer.