TinyMCE: strip tags from pasted URLs before testing if they are embeddable.

Props siobhan, iseulde. Fixes #31158.
Built from https://develop.svn.wordpress.org/trunk@31817


git-svn-id: http://core.svn.wordpress.org/trunk@31799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-18 20:26:26 +00:00
parent c4a624aa22
commit b30d15cd4a
4 changed files with 21 additions and 7 deletions

View File

@ -167,9 +167,11 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
// matching view patterns, and transform the matches into
// view wrappers.
editor.on( 'BeforeSetContent', function( event ) {
var node;
var pastedStr = event.content,
trim = tinymce.trim,
node;
if ( ! event.content ) {
if ( ! pastedStr ) {
return;
}
@ -179,10 +181,22 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
node = editor.selection.getNode();
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
pastedStr = trim( pastedStr );
// When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
return;
if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
event.content = pastedStr;
node = editor.dom.getParent( node, function( node ) {
if ( node.parentNode === editor.getBody() ) {
return node;
}
} );
if ( node.nodeName !== 'P' || trim( node.textContent ) || trim( node.innerText ) ) {
return;
}
}
event.content = wp.mce.views.setMarkers( event.content );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta1-31816';
$wp_version = '4.2-beta1-31817';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.