Make WordPress Core

Ticket #41052: 41052-2.video.patch

File 41052-2.video.patch, 2.5 KB (added by octalmage, 8 years ago)

Patch didn't apply, refreshed at 4.8.2.

  • src/wp-admin/js/widgets/media-widgets.js

     
    146146                                         */
    147147                                        fetch: function() {
    148148                                                var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url, re, youTubeEmbedMatch; // eslint-disable-line consistent-this
     149                                                url = embedLinkView.model.get( 'url' );
    149150
    150151                                                if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) {
    151152                                                        embedLinkView.dfd.abort();
     
    152153                                                }
    153154
    154155                                                // Abort if the URL field was emptied out.
    155                                                 if ( ! embedLinkView.model.get( 'url' ) ) {
     156                                                if ( ! url ) {
    156157                                                        embedLinkView.setErrorNotice( '' );
    157158                                                        return;
    158159                                                }
    159160
     161                                                // only proceed with embed if the field contains more than 11 characters
     162                                                // Example: http://a.io is 11 chars
     163                                                if ( url && ( url.length < 11 || ! url.match(/(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/) ) ) {
     164                                                        var embedLinkView = this; // eslint-disable-line consistent-this
     165                                                        $( '#embed-url-field' ).addClass( 'invalid' );
     166                                                        embedLinkView.setAddToWidgetButtonDisabled( true );
     167                                                        return;
     168                                                }
     169
    160170                                                fetchSuccess = function( response ) {
    161171                                                        embedLinkView.renderoEmbed({
    162172                                                                data: {
     
    170180                                                };
    171181
    172182                                                urlParser = document.createElement( 'a' );
    173                                                 urlParser.href = embedLinkView.model.get( 'url' );
     183                                                urlParser.href = url;
    174184                                                matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ );
    175185                                                if ( matches ) {
    176186                                                        fileExt = matches[1];
     
    191201                                                }
    192202
    193203                                                // Support YouTube embed links.
    194                                                 url = embedLinkView.model.get( 'url' );
    195204                                                re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/;
    196205                                                youTubeEmbedMatch = re.exec( url );
    197206                                                if ( youTubeEmbedMatch ) {
  • src/wp-includes/js/media-views.js

     
    47334733                this.$('.embed-container').hide().find('.embed-preview').empty();
    47344734                this.$( '.setting' ).hide();
    47354735
    4736                 // only proceed with embed if the field contains more than 11 characters
    4737                 // Example: http://a.io is 11 chars
    4738                 if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) {
     4736                // If URL is blank.
     4737                if ( ! url ) {
    47394738                        return;
    47404739                }
    47414740